Hashtable键值集合

    //Hashtable键值集合 键必须是维一的 类似于索引
            Hashtable ht = new Hashtable();
            ht.Add(1, "中国");
            ht.Add(2, 123);
            ht.Add(false, "错误的");
            ht[6] = "新来的"; //这也是一种添加方法
            foreach (var item in ht.Keys)
            {
                Console.WriteLine("ht的键是{0},值是{1}",item,ht[item]);
            }
            Console.ReadKey();

 

posted @ 2015-05-16 20:45  自由无风  阅读(391)  评论(0编辑  收藏  举报