StructuralComparisons.StructuralEqualityComparer 屬性

定義

取得預先定義的物件,這個物件會比較兩個物件的結構是否相等。Gets a predefined object that compares two objects for structural equality.

public:
 static property System::Collections::IEqualityComparer ^ StructuralEqualityComparer { System::Collections::IEqualityComparer ^ get(); };
public static System.Collections.IEqualityComparer StructuralEqualityComparer { get; }
member this.StructuralEqualityComparer : System.Collections.IEqualityComparer
Public Shared ReadOnly Property StructuralEqualityComparer As IEqualityComparer

屬性值

預先定義的物件,用來比較兩個集合物件的結構是否相等。A predefined object that is used to compare two collection objects for structural equality.

備註

當這個屬性所傳回的 IComparer 物件傳遞至集合物件的相等比較方法(例如 Array.IStructuralEquatable.Equals(Object, IEqualityComparer)Tuple<T1,T2,T3>.IStructuralEquatable.Equals(Object, IEqualityComparer))時,會針對陣列的每個成員或元組的每個元件呼叫其 IEqualityComparer.Equals 方法。When the IComparer object returned by this property is passed to the equality comparison method of a collection object, such as Array.IStructuralEquatable.Equals(Object, IEqualityComparer) or Tuple<T1,T2,T3>.IStructuralEquatable.Equals(Object, IEqualityComparer), its IEqualityComparer.Equals method is called for each member of an array or for each component of a tuple. 當集合物件的每個專案與另一個集合物件的對應專案比較時,此 Equals 方法的執行方式如下:This implementation of the Equals method behaves as follows when it compares each item of a collection object with the corresponding item of another collection object:

  • 如果兩個專案都 null,則會將這兩個專案視為相等。If both items are null, it considers the two items to be equal.

  • 如果一個專案是 null,但另一個專案不是,則會將這兩個專案視為不相等。If one item is null but the other item is not, it considers the two items to be unequal.

  • 如果比較中的第一個專案可以轉換成 IStructuralEquatable 物件(換句話說,如果它是實作為 IStructuralEquatable 介面的集合物件),則會呼叫 IStructuralEquatable.Equals 方法。If the first item in the comparison can be cast to an IStructuralEquatable object (in other words, if it is a collection object that implements the IStructuralEquatable interface), it calls the IStructuralEquatable.Equals method.

  • 如果比較中的第一個專案無法轉換成 IStructuralEquatable 物件(換句話說,如果它不是實作為 IStructuralEquatable 介面的集合物件),它會呼叫專案的 Equals 方法。If the first item in the comparison cannot be cast to an IStructuralEquatable object (in other words, if it is not a collection object that implements the IStructuralEquatable interface), it calls the item's Equals method.

適用於

另請參閱