Hashtable ht = new Hashtable();
Hashtable ht2 = new Hashtable();
ht.Add("Victor", 2000);
ht.Add("Bill", 3000);
ht2.Add("Bill", 1500);
ht2.Add("Michael", 4000);
foreach (string key in ht.Keys)
{
if (ht2.ContainsKey(key))
{
if (ht[key] == ht2[key]) //用这种方法 利用key来从hashtable中取值
{
Console.WriteLine("Key is:{0}, value is {1},equel", key, ht[key]);
}
else
{
Console.WriteLine("Key is:{0}, not equel", key);
}
break;
}
}
Hashtable ht2 = new Hashtable();
ht.Add("Victor", 2000);
ht.Add("Bill", 3000);
ht2.Add("Bill", 1500);
ht2.Add("Michael", 4000);
foreach (string key in ht.Keys)
{
if (ht2.ContainsKey(key))
{
if (ht[key] == ht2[key]) //用这种方法 利用key来从hashtable中取值
{
Console.WriteLine("Key is:{0}, value is {1},equel", key, ht[key]);
}
else
{
Console.WriteLine("Key is:{0}, not equel", key);
}
break;
}
}