Skip to content

Instantly share code, notes, and snippets.

@icodeintx
Last active July 10, 2022 17:50
Show Gist options
  • Save icodeintx/5006fe05fa2399a4bb6fa9cd35b1fa73 to your computer and use it in GitHub Desktop.
Save icodeintx/5006fe05fa2399a4bb6fa9cd35b1fa73 to your computer and use it in GitHub Desktop.
//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