dotnet / dotnet/dotnet-api-docs
Better guidance on IEquatable for sealed classes
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
IEquatable should only really be used on sealed classes, if I understand correctly. There is no mention of this in the documentation and it really is quite crucial and can create very surprising equality comparisons if it is defined on a parent class, and / or child class. Non terminal classes in a class tree should only implement `Equals(object)` if my understanding is correct.
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: bb62163e-a22d-2759-5ba5-b35fee7f7387
* Version Independent ID: 7a6d292b-6ec0-f9ae-c505-428136ef7435
* Content: [IEquatable<T> Interface (System)](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1?view=netframework-4.7.2)
* Content Source: [xml/System/IEquatable`1.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System/IEquatable`1.xml)
* Product: **dotnet-api**
* GitHub Login: @rpetrusha
* Microsoft Alias: **ronpet**
Contributor guide
Assessment
This issue has not been assessed yet.