I need to access the Dictionary by it's index (not the key). How do I go about doing this?
Thanks.
Printable View
I need to access the Dictionary by it's index (not the key). How do I go about doing this?
Thanks.
You don't. A Dictionary has no concept of order, only of correspondence between key and value. You can loop through all the values using the Values property. You can also loop through all the Keys using the Keys property, then getting the value for each key if desired. If order is important then you can use a SortedDictionary or SortedList.
Hmm Ok. I just feed it to List<Something> list = new List<Something>(myDictionary.Values) and then I'll get the list[0], list[3]...
Thanks.