摘要:使用 IDictionaryEnumerator 取出 HashTable 的值
static void Main(string[] args)
{
Hashtable hash = new Hashtable();
hash.Add("Jn", "January");
hash.Add("Fb", "February");
hash.Add("Mr", "March");
hash.Add("Ap", "April");
hash.Add("Jun", "June");
hash.Add("Jl", "July");
LoopHashtable(hash);
}
private static void LoopHashtable(Hashtable hash)
{
IDictionaryEnumerator ide = hash.GetEnumerator();
while (ide.MoveNext())
{
Console.WriteLine("Key: {0} Value: {1}", ide.Key, ide.Value);
}
}