Possible Duplicate:
How do I get the nth element from a Dictionary?
If there's a Dictionary
with total of Y
items and we need N
th item when N
< Y
then how to achieve this?
Example:
Dictionary<int, string> items = new Dictionary<int, string>();
items.add(2, "Bob");
items.add(5, "Joe");
items.add(9, "Eve");
// We have 3 items in the dictionary.
// How to retrieve the second one without knowing the Key?
string item = GetNthItem(items, 2);
How to write GetNthItem()
?
Dictionary
is more appropriate than aList
. – BaldheadOrderedDictionary
is the answer whenSortedList
is appropriate there. – BaldheadDictionary
no item is added in my case. – Baldhead