i have a dictionary where the key is a date and the value is an object. is there anyway i can ensure that when i loop through this collection its in chronological order always even after adding and deleting items.
+4
A:
You can use LINQ:
foreach(var kvp in dictionary.OrderBy(kvp => kvp.Key)) {
//Use kvp.Key and kvp.Value
}
SLaks
2009-10-22 11:27:15
+2
A:
You can use SortedList:
http://msdn.microsoft.com/en-us/library/ms132319.aspx
or SortedDictionary: http://msdn.microsoft.com/en-us/library/f7fta44c.aspx
Rik
2009-10-22 11:27:27