遍历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());
}
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3