public bool Equals(TwoDPoint p) { // If parameter is null return false: if ((object)p == null) { return(false); } // Return true if the fields match: return((x == p.x) && (y == p.y)); }
public override bool Equals(Object obj) { // If parameter is null return false. if (obj == null) { return(false); } // If parameter cannot be cast to Point return false. TwoDPoint p = obj as TwoDPoint; if ((Object)p == null) { return(false); } // Return true if the fields match: return((x == p.x) && (y == p.y)); }