Skip to content

It's time to use "==" to check if objects are equal #94269

Closed Answered by tannergooding
yuyang9119 asked this question in Ideas
Discussion options

You must be logged in to vote

there's no reason to continue using IEqualityComparer & IEquatable

There are many reasons to continue using IEqualityComparer and IEquatable. The two primary reasons are:

  1. They are much more extensively supported throughout the entire .NET ecosystem
  2. Equals and == do not strictly do the same thing.

I think the first point doesn't really need much elaboration. object.Equals has been around for the entirety of .NET (20+ years). IEquatable<T> has been around since .NET Framework 2.0 (15+ years). While IEqualityOperators has only been around since .NET 7 (2+ years).

The second point requires a bit of elaboration. Namely, object.Equals and IEquatable<T>.Equals have an overall requirement and…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@yuyang9119
Comment options

@tannergooding
Comment options

@yuyang9119
Comment options

@yuyang9119
Comment options

@tannergooding
Comment options

Answer selected by tannergooding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants