You need to check zeros with every method that takes parameters making your class.
public class Effect { public static bool operator == ( Effect a, Effect b ) { if (a == null) && (b == null) return true; if (a == null) return false; return a.Equals ( b ); } public static bool operator != ( Effect a, Effect b ) { return !(a == b); } public bool Equals ( Effect effect ) { if (b == null) return false; return this.TypeID.Equals ( effect.TypeID ); } public override bool Equals ( object obj ) { if (obj == null) return false; return this.TypeID.Equals ( ( ( Effect ) obj ).TypeID ); } }
Other things to look for are GetHashCode, which should be implemented if equality holds, and the fact that GetHashCode should only be implemented in immutable properties if this object will be used in a dictionary or similar object that compares elements using a hash -code.
source share