currentSC = (ShoppingCars)myEnumerator.Key;
...
ht.Remove(currentSC);这时currentSC不是Key类型的吧?

解决方案 »

  1.   

    1。
    你的问题描述的如此深奥,语言晦涩,别字N多2。
    ShoppingCars sc = (ShoppingCars)this.dlShopCart.DataKeys[e.Item.ItemIndex];
    ========
    DataKeys 里面存在是 ShoppinsCars 对象?
    通常 DataKeys ,顾名思义,键,应该存在是 ShoppingCar 的标识
    ShoppingCars SC = (ShoppingCars)myEnumerator.Key;
    if (sc.BookID == SC.BookID)
    {
    currentSC = (ShoppingCars)myEnumerator.Key;
    break;
    }
    else
    {
    currentSC = null;
    }
    =============
    这段代码也是如此的晦涩难懂,不直观3。
    到底 Hashtable 中 key 和 value 分别存的是什么啊?