日期:2014-05-20  浏览次数:20717 次

Hashtable的问题
我刚从6。0转到.net   ,在c++2005中使用Hashtable,大概原型是这样
ref   class   PointPair:   public   IComparable  
{
public:
  int   First;
  int   Second;
.....
  virtual   bool   Equals(PointPair^   p)
{
  if((First   ==p-> First   &&   Second   ==p-> Second)   ||   (First   ==p-> Second   &&   Second   ==p-> First))
{
return   true;
}
else
{
return   false;
}}
使用hashtable时添加键值为下面的格式
    ht-> add(gcnew   PointPair(p1,p2),value);
可查找时按如下格式却找不到
    ht-> ContainKey(gcnew   PointPair(p1,p2));
查找相同键值始终返回false

请问这是不是引用出的问题,怎么解决
请问在C#中这种问题怎么解决的

------解决方案--------------------
好像键有问题,是不是会引起散列不正常
------解决方案--------------------
try

重写 PointPair
的GetHashCode