非泛型遍历输出
SortedList s1 = new 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); }
泛型遍历输出
SortedList<string,int> s1 = new SortedList<string,int>(); s1["c"] = 41; s1["a"] = 42; s1["d"] = 11; s1["b"] = 13; foreach (KeyValuePair<string,int> element in s1) { string s =element.Key; int i = element.Value; Console.WriteLine("{0},{1}", s, i); }