利用 SortedDictionary、SortedList 一句代码排序
ITPOW2018/3/1 9:58:26
Dictionary<string, string> items = new Dictionary<string, string>(); items.Add("b", "b"); items.Add("a", "a"); items.Add("c", "c"); // 用 SortedDictionary 排序 SortedDictionary<string, string> sitems = new SortedDictionary<string, string>(items); foreach (var item in sitems) { Response.Write(item.Key); // a、b、c } // 用 SortedList 排序 SortedList<string, string> sitems2 = new SortedList<string, string>(items); foreach (var item in sitems2) { Response.Write(item.Key); // a、b、c }
<<返回首页<<