遍历Hashtable 的几种方法
今天图老师小编给大家精心推荐个遍历Hashtable 的几种方法教程,一起来看看过程究竟如何进行吧!喜欢还请点个赞哦~
IDictionaryEnumerator enumerator = thProduct.GetEnumerator();
while (enumerator.MoveNext())
{
arrKey.Add("@"+enumerator.Key.ToString()); // Hashtable关健字
arrValue.Add(enumerator.Value.ToString()); // Hashtable值
}
方法二:
using System.Collections;
HashTable objHasTab;
// Setting values to objHasTab
foreach (DictionaryEntry objDE in objHasTab)
{
Console.WriteLine(objDE.Key.ToString());
Console.WriteLine(objDE.Value.ToString());
}