遍历HasTable对象的两种方法

方法一
 foreach (System.Collections.DictionaryEntry de in objHasTab)
{
    //注意HastTable内存储的默认类型是object,需要进行转换才可以输出
    Console.WriteLine(de.Key.ToString());
    Console.WriteLine(de.Value.ToString());
}

方法二
System.Collections.IDictionaryEnumerator enumerator = objHashTablet.GetEnumerator();
while (enumerator.MoveNext())
{
    Console.WriteLine(enumerator.Key);         // Hashtable关健字
    Console.WriteLine(enumerator.Value);      // Hashtable值
}

原文地址:https://www.cnblogs.com/luyinghuai/p/1268713.html