Sunday, December 16, 2007

how to iterate key and value from hashTable

Hashtable ht = new Hashtable();
ht.Add("A1", "a111111");
ht.Add("A2", "a222222");
ht.Add("A3", "a333333");
ht.Add("A4", "a444444");
ht.Add("A5", "a555555");
ht.Add("A6", "a666666");
ht.Add("A7", "a777777");
ht.Add("A8", "a888888");

IDictionaryEnumerator iDict;
iDict = ht.GetEnumerator();

while (iDict.MoveNext())
{
string key = iDict.Key.ToString();
string Value = iDict.Value.ToString();
}

No comments: