// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; namespace E { public class MainClass { public static void Main(string[] args) { SortedDictionary dic = new SortedDictionary(); dic.Add(4, "DDDD"); dic.Add(2, "BB"); dic.Add(1, "A"); dic.Add(3, "CCC"); dic.Add(5, "EEEEE"); foreach(KeyValuePair kvp in dic) { Console.WriteLine(kvp.Key + " " + kvp.Value); } foreach(int key in dic.Keys) { Console.WriteLine(key + " " + dic[key]); } Console.WriteLine(dic.Keys[0] + " " + dic.Keys[dic.Keys.Count-1]); } } }