本文共 891 字,大约阅读时间需要 2 分钟。
初始化 SortedList
public SortedList( int capacity, IComparercomparer)
参数讲解:
capacity类型:System.Int32
SortedListSortedList sList = new SortedList(new MyComparer()); UserModel UserModel1 = new UserModel(); UserModel1.Name = "test1"; UserModel1.Age = 20; UserModel UserModel2 = new UserModel(); UserModel2.Name = "test3"; UserModel2.Age = 1; UserModel UserModel3 = new UserModel(); UserModel3.Name = "test2"; UserModel3.Age = 2; sList.Add("21", UserModel1); sList.Add("51", UserModel2); sList.Add("11", UserModel3); _cache.Set("User1", sList); foreach (DictionaryEntry element in sList) { string name = (string)element.Key; int age = (int)element.Value; }
转载地址:http://kgjmo.baihongyu.com/