有序字典

/*
有序字典
SortedDictionary类的使用,它是一个二叉搜索树
它比SortedList的元素插入和删除速度比较快。
SortedList的内存比它占用的要少,在已排序的数据填充集合时SortedList要快。
*/
using System.Collections.Generic;

namespace Frank
{
	public class Test
    {
		//程序入口
        public static void Main(string[] args)
        {
			SortedDictionary<string,string> sd = new SortedDictionary<string,string>();
			sd.Add("a","1");
			sd.Add("d","3");
			sd.Add("c","2");
			foreach(string item in sd.Keys)
			{
				System.Console.WriteLine(sd[item]);//自动排序value值,value里面的对象必须实现IComparable接口
			}
        }
	}
}

  

posted on 2013-12-06 15:21  wp456  阅读(169)  评论(0)    收藏  举报

导航