Get an IDictionaryEnumerator that iterates through the Hashtable in CSharp
Description
The following code shows how to get an IDictionaryEnumerator that iterates through the Hashtable.
Example
using System;/* w w w. ja v a 2 s . c o m*/
using System.Collections;
public class HashtableExample
{
public static void Main()
{
Hashtable myHT = new Hashtable();
myHT.Add("1", "4");
myHT.Add("2", "5");
myHT.Add("3", "6");
IDictionaryEnumerator denum = myHT.GetEnumerator();
DictionaryEntry dentry;
while (denum.MoveNext())
{
dentry = (DictionaryEntry) denum.Current;
Console.WriteLine(" {0,-17}{1}", dentry.Key, dentry.Value);
}
}
}
The code above generates the following result.