I can order an ordered dictionary by date

I have a dictionary where key is date and value is object. do i exist anyway, i can guarantee that when i go through this collection in chronological order always even after adding and removing items.

+2


source to share


3 answers


You need to use SortedDictionary



+7


source


You can use LINQ:



foreach(var kvp in dictionary.OrderBy(kvp => kvp.Key)) {
    //Use kvp.Key and kvp.Value
}

      

+4


source


+2


source







All Articles