HashTable的遍历

 namespace @string
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable HS = new Hashtable();
            HS.Add(1, "apple");//add 方法是想添加键值对
            HS.Add(2, "orange");
            HS.Add(3, "watermelon");
            HS.Add(4, "banana");
            HS.Add(5, "grape");
            HS.Add(6, "melon");
            foreach (DictionaryEntry de in HS)//dictionaryEntry是这个hashtable的入口点
            {
                Console.WriteLine(de.Value.ToString());
                Console.WriteLine(de.Key.ToString());
            }
        }
    }
}
以上代码实现遍历整个HashTable。res3
原文地址:https://www.cnblogs.com/jessie/p/1440560.html