Hashtable ht = new Hashtable();
ht.Add("ht1", "111");
ht.Add("ht2", "222");
ht.Add("ht3", "333");
//定義壹個Hashtable
string key = null;
foreach (System.Collections.DictionaryEntry de in ht)
{
if (de.Value.ToString() == "222")
{
key=de.Key.ToString();//得到key
break;//退出foreach遍歷
}
}
Response.Write(key);//輸出ht2