Skip to content

Commit 8771ec1

Browse files
authored
Update interfaces.md (#42657)
This commit makes it more clear the implementing class of the `IEquatable<T>` method must be of type `T ` in order to be able to determine if its equal to other instances of type `T`. Confusion might arise in certain case. For example, if we have a class of type `MyClass` that implements `IEquatable<MyOtherClass>`, then we can't use `IEquatable`'s method `Equals` to compare an instance of `MyClass` with another instance of `MyClass`
1 parent d436fed commit 8771ec1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/csharp/fundamentals/types/interfaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ You define an interface by using the [`interface`](../../language-reference/keyw
1818

1919
The name of an interface must be a valid C# [identifier name](../coding-style/identifier-names.md). By convention, interface names begin with a capital `I`.
2020

21-
Any class or struct that implements the <xref:System.IEquatable%601> interface must contain a definition for an <xref:System.IEquatable%601.Equals%2A> method that matches the signature that the interface specifies. As a result, you can count on a class that implements `IEquatable<T>` to contain an `Equals` method with which an instance of the class can determine whether it's equal to another instance of the same class.
21+
Any class or struct that implements the <xref:System.IEquatable%601> interface must contain a definition for an <xref:System.IEquatable%601.Equals%2A> method that matches the signature that the interface specifies. As a result, you can count on a class of type `T` that implements `IEquatable<T>` to contain an `Equals` method with which an instance of this class can determine whether it's equal to another instance of the same class.
2222

2323
The definition of `IEquatable<T>` doesn't provide an implementation for `Equals`. A class or struct can implement multiple interfaces, but a class can only inherit from a single class.
2424

0 commit comments

Comments
 (0)