Defines a generalized method that a value type or class implements to create a type-specific method for determining equality of instances.
Assembly: mscorlib (in mscorlib.dll)
Indicates whether the current object is equal to another object of the same type.
This interface is implemented by types whose values can be equated (for example, the numeric and string classes). A value type or class implements the Equals method to create a type-specific method suitable for determining equality of instances.
The IComparable<'T> interface defines the CompareTo method, which determines the sort order of instances of the implementing type. The interface defines the Equals method, which determines the equality of instances of the implementing type.
The Dictionary<'TKey, 'TValue>, List<'T>, and LinkedList<'T> when testing for equality in such methods as Contains, IndexOf, LastIndexOf, and Remove. It should be implemented for any object that might be stored in a generic collection.interface is used by generic collection objects such as
Notes to Implementers:
Replace the type parameter of theinterface with the type that is implementing this interface.
If you implement Object.Equals(Object) and GetHashCode so that their behavior is consistent with that of the IEquatable<'T>.Equals method. If you do override Object.Equals(Object), your overridden implementation is also called in calls to the static Equals(System.Object, System.Object) method on your class. In addition, you should overload the op_Equality and op_Inequality operators. This ensures that all tests for equality return consistent results., you should also override the base class implementations of
For a value type, you should always implement Object.Equals(Object) for better performance. Object.Equals boxes value types and relies on reflection to compare two values for equality. Both your implementation of Equals and your override of Object.Equals should return consistent results.and override
Available since 8
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1