哈希表遍历

           Hashtable hash = new Hashtable();
           hash.Add("pg", "apple");
           hash.Add("xj", "banana");
           hash.Add("jz", "oriage");
           hash.Add("lz", "pear");
           hash.Add("tz", "peach");

           //recusively show key and value
           foreach (DictionaryEntry item in hash)
           {
               Console.WriteLine( item.Key + "  " + item.Value);
           }

            //recusively key
            foreach (var key in hash.Keys)
            {
                Console.WriteLine(key);
            }

            //recusive value
            foreach (var value in hash.Values)
            {
                Console.WriteLine(value);
            }

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