using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace SortedList_test { class Program { static void Main() { SortedList s1 = new SortedList(); //创建一个SortedList实例 s1["c"]=41; //关键字为中括号里的字母,值为数字 s1["a"] = 42; s1["d"] = 11; s1["b"] = 13; foreach (DictionaryEntry element in s1) { string s = (string)element.Key; int i = (int)element.Value; Console.WriteLine("{0},{1}",s,i); } } } }