SortedList in C# is nice...

Submitted by matthias hub on Mon, 04/26/2010 - 10:32
Just found this class while looking for a automatically alphabetically sorted-by-key hashtable (from http://msdn.microsoft.com/en-us/library/system.collections.sortedlist.aspx):

using System;
using System.Collections;
public class SamplesSortedList {
public static void Main() {
// Creates and initializes a new SortedList.
SortedList slides = new SortedList();
slides.Add("0", "slide1");
slides.Add("2", "slide3");
slides.Add("1", "slide2");
// Displays the properties and values of the SortedList.
for (int i = 0; i < slides.Count; i++) {
Console.WriteLine("{0}:{1}", slides.GetKey(i), slides.GetByIndex(i));
}
Console.WriteLine();
}