use generic SortedList
Published: 9. October 2011 | Updated: 9. October 2011License: Microsoft Public License (MS-PL)
Categories: Collections
Tags: C# Collections
Import namespace
using System.Collections;
Code
var sorted = new SortedList<string, int>(); sorted["d"] = 1; sorted["e"] = 2; sorted["c"] = 3; sorted["a"] = 4; sorted["b"] = 5; foreach (KeyValuePair<string, int> pair in sorted) { Console.WriteLine("{0} = {1}", pair.Key, pair.Value); }Console Output:
a = 4
b = 5
c = 3
d = 1
e = 2
b = 5
c = 3
d = 1
e = 2
| Send us feedback about this snippet » |





