StructuralComparisons.StructuralComparer 属性
定义
获取可执行两个对象的结构比较的预定义对象。Gets a predefined object that performs a structural comparison of two objects.
public:
static property System::Collections::IComparer ^ StructuralComparer { System::Collections::IComparer ^ get(); };
public static System.Collections.IComparer StructuralComparer { get; }
member this.StructuralComparer : System.Collections.IComparer
Public Shared ReadOnly Property StructuralComparer As IComparer
属性值
一个用于执行两个集合对象的结构比较的预定义对象。A predefined object that is used to perform a structural comparison of two collection objects.
注解
如果将 IComparer 此属性返回的对象传递给集合对象(如或)的比较方法, Array.IStructuralComparable.CompareTo(Object, IComparer) Tuple<T1,T2,T3>.IStructuralComparable.CompareTo(Object, IComparer) Compare 则将为数组的每个成员或元组的每个组件调用其方法。When the IComparer object returned by this property is passed to the comparison method of a collection object, such as Array.IStructuralComparable.CompareTo(Object, IComparer) or Tuple<T1,T2,T3>.IStructuralComparable.CompareTo(Object, IComparer), its Compare method is called for each member of an array or for each component of a tuple. 此方法的实现 Compare 在将集合对象的每个项与另一个集合对象的相应项进行比较时的行为如下:This implementation of the Compare method behaves as follows when it compares each item of a collection object with the corresponding item of another collection object:
它认为两个项
null相等,并将空项视为小于非空项。It considers two items that arenullto be equal, and considers a null item to be less than an item that is not null.如果比较中的第一项可以转换为 IStructuralComparable 对象 (换言之,如果它是实现接口的集合对象 IStructuralComparable) ,则它将调用 CompareTo 方法。If the first item in the comparison can be cast to an IStructuralComparable object (in other words, if it is a collection object that implements the IStructuralComparable interface), it calls the CompareTo method.
如果比较中的第一项无法转换为 IStructuralComparable 对象 (换言之,如果它不是实现接口的集合对象 IStructuralComparable) ,它将调用
Comparer.Default.Compare方法。If the first item in the comparison cannot be cast to an IStructuralComparable object (in other words, if it is not a collection object that implements the IStructuralComparable interface), it calls theComparer.Default.Comparemethod.