Hashtable的遍历

两种方法:
1.DictionaryEntry
foreach( DictionaryEntry de in hashTable)
{
console.WriteLine(
"Key -- {0}; Value --{1}.", de.Key, de.Value);
}
2.IDictionaryEnumerator
Hashtable food = new Hashtable();
IDictionaryEnumerator myEnumerator  
= food.GetEnumerator();
while(myEnumerator.MoveNext())
{
       strfoodlist
= strfoodlist + "\n\n" + myEnumerator.Key.ToString();
       strfoodlist
= strfoodlist + ":\t" +myEnumerator.Value.ToString();
}

posted on 2009-10-13 11:47  alon  阅读(156)  评论(0)    收藏  举报

导航