© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4mo ago•
64 replies
webczat

✅ Equality confusion

My question is about equality on reference types.
Most ms docs state that full equality contract should be implemented only for objects having value semantics, although examples usually talk about things like complex numbers. Records are just glorified classes with multiple properties and have that implemented too. By full equality contract I mean
object.Equals
object.Equals
+
GetHashCode
GetHashCode
+
IEquatable
IEquatable
+ operators.
Docs on
IEquatable<T>
IEquatable<T>
say that if you implement it you should also implement operators.
Docs for object.Equals say that most reference types shouldn't override operators even if they implement equals.
Why would a type implement Equals but not operators and not IEquatable<T>?
Ah, and there is even an analyzer warning about implementing operators.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ ✅ Struct equality
C#CC# / help
3y ago
✅ Serilog Confusion
C#CC# / help
11mo ago
Attributes confusion
C#CC# / help
2y ago
Next page