Hashtable.GetEnumerator Method returns an IDictionaryEnumerator that iterates through the Hashtable.
using System;
using System.Collections;
public class HashtableExample
{
public static void Main()
{
Hashtable clouds = new Hashtable();
clouds.Add("A", "a");
clouds.Add("B", "b");
clouds.Add("C", "c");
IDictionaryEnumerator denum = clouds.GetEnumerator();
DictionaryEntry dentry;
while (denum.MoveNext())
{
dentry = (DictionaryEntry) denum.Current;
Console.WriteLine(" {0,-17}{1}", dentry.Key, dentry.Value);
}
foreach (DictionaryEntry de in clouds)
{
Console.WriteLine(" {0,-17}{1}", de.Key, de.Value);
}
}
}
Related examples in the same category