c#遍历HashTable
方式一:
foreach (System.Collections.DictionaryEntry objDE in objHasTab)
{
Console.WriteLine(objDE.Key.ToString());
Console.WriteLine(objDE.Value.ToString());
}
{
Console.WriteLine(objDE.Key.ToString());
Console.WriteLine(objDE.Value.ToString());
}
方式二:
System.Collections.IDictionaryEnumerator enumerator = objHashTablet.GetEnumerator();
while (enumerator.MoveNext())
{
Console.WriteLine(enumerator.Key);
Console.WriteLine(enumerator.Value);
}
while (enumerator.MoveNext())
{
Console.WriteLine(enumerator.Key);
Console.WriteLine(enumerator.Value);
}