StructuralComparisons.StructuralEqualityComparer Property

Definition

Gets a predefined object that compares two objects for structural equality.

C#
public static System.Collections.IEqualityComparer StructuralEqualityComparer { get; }

Property Value

A predefined object that is used to compare two collection objects for structural equality.

Remarks

When the IEqualityComparer 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. 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:

  • If both items are null, it considers the two items to be equal.

  • If one item is null but the other item is not, it considers the two items to be unequal.

  • 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.

  • 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.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

See also