哈希表问题 
 如何 按照 哈希表的 值删除 而不是按照哈希表的KEY 因为只提供了KEY 删除 求快速解答

解决方案 »

  1.   

    好像是只能循环来查找并删除了,比如:Hashtable ht = new Hashtable();
    ht.Add(1, 123);
    ht.Add(2, 234);
    ht.Add(3, 345);object deleteKey = null;
    foreach(object key in ht.Keys)
    {
    if (object.Equals(ht[key], 234))
    {
    deleteKey = key;
    break;
    }
    }
    if (deleteKey != null)
    {
    ht.Remove(deleteKey);
    }
      

  2.   

    那就不要用 hashtable 存储了,还不如直接线性表,如数组,ArrayList ... 来的划算
      

  3.   

    如果你的key不同值相同怎么办??
    foreach会抛异常最好还是改变存储方式