using System.Collections;
static void Main(string[] args)
{
TestHashtable();
}
//------------------------------------------------------
// 哈希表(Hashtable)
public static void TestHashtable()
{
Hashtable ht = new Hashtable();
ht.Add("001", "a");
ht.Add("002", "b");
ht.Add("003", "c");
if (ht.ContainsValue("a"))
{
Console.WriteLine("存在");
}
else
{
ht.Add("004", "c");
}
// 获取键的集合
ICollection key = ht.Keys;
foreach (string k in key)
{
Console.WriteLine(k + ": " + ht[k]);
}
Console.ReadLine();
}
//------------------------------------------------------