一 排列列表的定义:
它可以使用键和索引来访问列表中的项。排序列表是数组和哈希表的组合。它包含一个可使用键或索引访问各项的列表。如果您使用索引访问各项,则它是一个动态数组(ArrayList),如果您使用键访问各项,则它是一个哈希表(Hashtable)。集合中的各项总是按键值排序
二 排列列表的属性:
三 排列列表的方法
四 控制台中的代码
SortedList sl = new SortedList();
sl.Add("北京", "帝都");
sl.Add("上海", "魔都");
sl.Add("广州", "省会");
sl.Add("深圳", "特区");
sl.Add("1", "first");
sl.Add("A", "d");
sl.Add("a", "A");
foreach (DictionaryEntry item in sl)
{
Console.Write(item.Key+" ");
Console.WriteLine(item.Value+" ");
}
Console.WriteLine();
// Console.WriteLine(sl.ContainsKey("上海"));
//Console.WriteLine(sl.GetByIndex(1));
// Console.WriteLine(sl.GetKey(1));
//Console.WriteLine(sl.IndexOfKey("广州"));
sl.Remove("广州");
foreach (DictionaryEntry item in sl)
{
Console.Write(item.Key+" ");
Console.WriteLine(item.Value + " ");
}
Console.ReadLine();