I have a pretty complex object and I need to get uniqueness of these objects. One solution can be done by overriding GetHashCode()
. I have implemented a code noted below:
public override int GetHashCode()
{
return this._complexObject1.GetHashCode() ^
this._complexObject2.GetHashCode() ^
this._complexObject3.GetHashCode() ^
this._complexObject4.GetHashCode() ^
this._complexObject5.GetHashCode() ^
this._complexObject6.GetHashCode() ^
this._complexObject7.GetHashCode() ^
this._complexObject8.GetHashCode();
}
These complex objects also overrides GetHashCode()
and does similar operations.
My project requires uniqueness of these objects which I deal with these very frequently, and data inside also changes in various ways and places.
I need a faster way to find uniqueness of these complex objects, which need to consider performance and memory.
Thanks in advance
Munim
GetHashCode()
is probably the wrong thing to start with - besides, it can only guarantee non-equality (it cannot be used to test for equality). – MicrofaradGetHashCode()
to check the objects are not equal, and this is what I need to do – Keil