Difference between Key and _key and value versus V

2019-03-06 23:31发布

问题:

Does anybody knows the different between Key and _key in the List<> and Dictionary, how to approach them and manipulate them?

回答1:

From your question and examples, I'm guessing you are enumerating a collection of DictionaryEntry structures. If that is the case, _key is a private member variable and Key is a public property. You can access Key from your code because it is public, but not _key because it is private.

The debugger is able to show you both values via reflection. You should only use the Key property in your code.