Почему следующая логическая переменная «существовать» получает значение false ???
foreach (Cell existCell in this.decoratorByCell.Keys)
{
//this call yield the same hashcode for both cells. still exist==false
bool exist =
this.decoratorByCell.ContainsKey(existCell);
}
Я переопределил методы GetHashCode () и Equals () следующим образом:
public override int GetHashCode()
{
string nodePath = GetNodePath();
return nodePath.GetHashCode() + m_ownerColumn.GetHashCode();
}
public bool Equals(Cell other)
{
bool nodesEqual = (other.OwnerNode == null && this.OwnerNode == null) || (other.GetNodePath() == this.GetNodePath());
bool columnsEqual = (other.OwnerColumn == null && this.OwnerColumn == null) || (other.OwnerColumn == this.OwnerColumn);
bool treesEqual = (this.m_ownerTree == other.m_ownerTree);
return (nodesEqual && columnsEqual && treesEqual);
}