c#遍歷HashTable

wl1121發表於2009-05-26

 

 foreach (System.Collections.DictionaryEntry objDE in objHasTab)
{
    Console.WriteLine(objDE.Key.ToString());
    Console.WriteLine(objDE.Value.ToString());
}


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

foreach(object key in objHastab.keys)
{
Element e=(Element)objHashtab[key];
}

相關文章