Last active
July 10, 2022 17:50
-
-
Save icodeintx/5006fe05fa2399a4bb6fa9cd35b1fa73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Implement IEquatable<> interface and have these methods below | |
public bool Equals(User other) | |
{ | |
return IsEqual(other); | |
} | |
public override bool Equals(Object obj) | |
{ | |
//Check for null and compare run-time types. | |
if ((obj == null) || !this.GetType().Equals(obj.GetType())) | |
{ | |
return false; | |
} | |
else | |
{ | |
User model = (User)obj; | |
return IsEqual(model); | |
} | |
} | |
private bool IsEqual(User other) | |
{ | |
if (this.UserID == other.UserID) | |
{ | |
return true; | |
} | |
else | |
{ | |
return this.EmailAddress == other.EmailAddress; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment