Hashtable 键值对集合

键值对集合

 static void Main(string[] args)
        {
            //创建一个键值对集合对象
            Hashtable ht = new Hashtable();

            //键和值
            ht.Add(1, "张三");
            ht.Add(2,  true);
            ht.Add(3,  '');

            //每一个键keys的对应的元素item遍历一遍
            foreach (var item in ht.Keys)
            {
                Console.WriteLine(ht[item]);
            }
        }

 

posted @ 2023-02-07 10:56  春哥博客  阅读(21)  评论(0)    收藏  举报