public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } if (ReferenceEquals(this, obj)) { return(true); } if (this.GetHashCode() != obj.GetHashCode()) { return(false); } Employee other = (Employee)obj; if (!base.Equals(other)) { return(false); } if (ReferenceEquals(LanId, null)) { return(ReferenceEquals(other.LanId, null)); } return(LanId.Equals(other.LanId)); }
/// <summary> /// GetHashCode() should not change over the life of the object. This only works /// when values used within the hashCode are immutable. This object does *not* /// keep a consistent HashCode over the lifetime of the object since the variables /// upon which it's based (Name) is mutable. /// </summary> public override int GetHashCode() { int hashCode = base.GetHashCode(); int prime = 31; hashCode = hashCode * prime + LanId == null ? 0 : LanId.GetHashCode(); return(hashCode); }