C#集合-有序列表

  
    
/// SortedList <TKey, TValue> 。这个类按照键给元素排序
#region 有序表测试

/// <summary>
/// 有序表测试
/// </summary>
public class TestSortedList
{
public void TestSortedListMethod()
{
SortedList
< string , string > strSortedList = new SortedList < string , string > ();
strSortedList.Add(
" 环境恶化 " , " 台风 " );
strSortedList.Add(
" 环境变化 " , " 沙尘暴 " );
strSortedList.Add(
" 环境破坏 " , " 地震 " );
/// 显示时,你会发现他与原来加入列表时的顺序不一样了,
/// 他已经被按键值排序了
foreach (var item in strSortedList)
{
Console.WriteLine(item.Key);
}
/// 其它特性基本都是一样的
/// 这里不多做例子,不明白就跟贴吧
}
}
#endregion

你可能感兴趣的:(C#)