Provide your own IEqualityComparer
to the dictionary, as it does not know how to compare XYZ
class (strictly speaking, it compares them by reference):
class XYZEqualityComparer : IEqualityComparer<XYZ>
{
public bool Equals(XYZ a, XYZ b)
{
return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
}
public int GetHashCode(XYZ x)
{
int hash = x.X ^ x.Y ^ x.Z;
return hash .GetHashCode();
}
}
and then:
Dictionary<XYZ, bool> prevPnts = new Dictionary<XYZ, bool>(new XYZEqualityComparer());
Note: My implementation of GetHashCode
is only exemplary. Read What is the best algorithm for an overridden System.Object.GetHashCode? for better alternatives.