Kai77
asked on
Get key by idex from a ordered dictionary
How can I retrieve the key by using the index?
I can retrieve the value by index like: oOrderedDictionary[0].toSt ring()
Is there something similair for a key value?
(I believe a sortedlist has a GetKey() method, but the ordered dictionary does not?)
I can retrieve the value by index like: oOrderedDictionary[0].toSt
Is there something similair for a key value?
(I believe a sortedlist has a GetKey() method, but the ordered dictionary does not?)
Have you tried using the TryGetValue method?
ASKER
I am using ASP.net 2.0 and intellisense does not say OrderDictionary has a TryGetValue method
Is there a reason you are using System.Collections.Special ized.Order edDictiona ry instead of System.Collections.Generic .Dictionar y<TKey,TVa lue>
ASKER
from what i undestand an ordered dictionary the sort order is ordered by the order in which you addes key-value pairs. Does the generic.dictionary do the same?
ASKER
I just took a quick look at the Generic.Dictionary .
I believe the TryGetValue needs you to enter a key and will return a value based on that key. What I need is to enter a index and get the key.
I believe the TryGetValue needs you to enter a key and will return a value based on that key. What I need is to enter a index and get the key.
If you require that the dictionary be sorted then you should use the generic SortedDictionary:
System.Collections.Generic .SortedDic tionary<TK ey, TValue>
System.Collections.Generic
I see what you are after now. I can't seem to find what you are after in any of the collections built into .NET. For some reason none of them allow you to get the key by an index.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.