SortedList Collection in C#
By Mash B
SortedList (in the System.Collections namespace) is a dictionary that consists of key/value pairs.
Both the key and the value can be any object. SortedList is sorted automatically by the key.
Example:
In any order you insert the data into collection , SortedList collection
reorders the data internally.
SortedList sl = new SortedList();
sl.Add("C", "Cat");
sl.Add("A", "Apple");
sl.Add("B", "Ball");
// Populate the data
foreach (DictionaryEntry de in sl)
Console.WriteLine(de.Value); // Outputs A B C
SortedList Collection in C# (775 Views)