public class User { public string UserId { get; set; } public string UserName { get; set; } public bool Equals(User user) => user.UserId.Equals(UserId); public override bool Equals(object o) => Equals(o as User); public override int GetHashCode() => UserId.GetHashCode(); }
Ref: