using System.Collections.Generic;
public static void Main()
SortedList<int,string> sortedList1 = new SortedList<int,string>();
sortedList1.Add(3, "Three");
sortedList1.Add(4, "Four");
sortedList1.Add(1, "One");
sortedList1.Add(5, "Five");
sortedList1.Add(2, "Two");
Console.WriteLine("sortedList1 has "+sortedList1.Count + " items in the list");
foreach(KeyValuePair<int,string> item in sortedList1 )
Console.WriteLine(item.Key + "" + item.Value);
SortedList<string,int> sortedList2 = new SortedList<string,int>();
sortedList2.Add("one", 1);
sortedList2.Add("two", 2);
sortedList2.Add("three", 3);
sortedList2.Add("four", 4);
sortedList2.Add("five", 5);
Console.WriteLine("sortedList2 has " + sortedList2.Count + " items in the list");
for (int i = 0; i < sortedList2.Count; i++)
Console.WriteLine("key: {0}, value: {1}", sortedList2.Keys[i], sortedList2.Values[i]);
SortedList<double,int?> sortedList3 = new SortedList<double,int?>()
sortedList3.Add(1.5, 100);
sortedList3.Add(3.5, 200);
sortedList3.Add(2.4, 300);
sortedList3.Add(2.3, null);
sortedList3.Add(1.1, null);
Console.WriteLine("sortedList3 has " + sortedList3.Count + " items in the list");
foreach(KeyValuePair<double,int?> kvp in sortedList3 )
Console.WriteLine("key: {0}, value: {1}", kvp.Key , kvp.Value );