IEqualityComparer IEqualityComparer IEqualityComparer IEqualityComparer Interface

定義

定義支援物件之相等比較的方法。Defines methods to support the comparison of objects for equality.

public interface class IEqualityComparer
[System.Runtime.InteropServices.ComVisible(true)]
public interface IEqualityComparer
type IEqualityComparer = interface
Public Interface IEqualityComparer
衍生
屬性

備註

這個介面允許實作自訂的相等比較的集合。This interface allows the implementation of customized equality comparison for collections. 也就是說,您可以在 建立您自己定義等號比較、,並指定與接受集合類型會使用此定義IEqualityComparer介面。That is, you can create your own definition of equality, and specify that this definition be used with a collection type that accepts the IEqualityComparer interface. 在.NET Framework 中,建構函式HashtableNameValueCollection,和OrderedDictionary集合型別會接受此介面。In the .NET Framework, constructors of the Hashtable, NameValueCollection, and OrderedDictionary collection types accept this interface.

這個介面的泛型版本,請參閱System.Collections.Generic.IEqualityComparer<T>For the generic version of this interface, see System.Collections.Generic.IEqualityComparer<T>.

IEqualityComparer介面支援只有相等比較。The IEqualityComparer interface supports only equality comparisons. 所提供的排序及順序比較自訂IComparer介面。Customization of comparisons for sorting and ordering is provided by the IComparer interface.

方法

Equals(Object, Object) Equals(Object, Object) Equals(Object, Object) Equals(Object, Object)

判斷指定的物件是否相等。Determines whether the specified objects are equal.

GetHashCode(Object) GetHashCode(Object) GetHashCode(Object) GetHashCode(Object)

傳回指定物件的雜湊碼。Returns a hash code for the specified object.

適用於

另請參閱