It's time to use "==" to check if objects are equal #94269
-
Now that we have the Object comparison ( |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
The new interface still need to be explicitly implemented by types. The unification would need more language and runtime support, especially adding implemented interfaces via extensions. |
Beta Was this translation helpful? Give feedback.
-
There are many reasons to continue using
I think the first point doesn't really need much elaboration. The second point requires a bit of elaboration. Namely, The most notable case for this is Which (of
|
Beta Was this translation helpful? Give feedback.
There are many reasons to continue using
IEqualityComparer
andIEquatable
. The two primary reasons are: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). WhileIEqualityOperators
has only been around since .NET 7 (2+ years).The second point requires a bit of elaboration. Namely,
object.Equals
andIEquatable<T>.Equals
have an overall requirement and…