|
-
Feb 28th, 2007, 09:19 PM
#1
Thread Starter
Fanatic Member
Accessing Dictionary by Index
I need to access the Dictionary by it's index (not the key). How do I go about doing this?
Thanks.
Last edited by nebulom; Feb 28th, 2007 at 10:43 PM.
-
Feb 28th, 2007, 10:09 PM
#2
Re: Accessing Dictionary by Index
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.
-
Feb 28th, 2007, 10:42 PM
#3
Thread Starter
Fanatic Member
Re: Accessing Dictionary by Index
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|