DataObjectItemComparer.Compare Method (String, String, Object, Object)

Compares a property of a data object with another data object property.

Namespace:  Microsoft.VisualStudio.Data
Assembly:  Microsoft.VisualStudio.Data (in Microsoft.VisualStudio.Data.dll)

Syntax

'宣言
Public Overridable Function Compare ( _
    typeName As String, _
    propertyName As String, _
    value1 As Object, _
    value2 As Object _
) As Integer
'使用
Dim instance As DataObjectItemComparer
Dim typeName As String
Dim propertyName As String
Dim value1 As Object
Dim value2 As Object
Dim returnValue As Integer

returnValue = instance.Compare(typeName, _
    propertyName, value1, value2)
public virtual int Compare(
    string typeName,
    string propertyName,
    Object value1,
    Object value2
)
public:
virtual int Compare(
    String^ typeName, 
    String^ propertyName, 
    Object^ value1, 
    Object^ value2
)
public function Compare(
    typeName : String, 
    propertyName : String, 
    value1 : Object, 
    value2 : Object
) : int

Parameters

  • propertyName
    Type: System.String

    The name of a property to compare.

Return Value

Type: System.Int32

Returns less than zero in cases where the identifier part is less than the specified value. Returns zero if the identifier part is equal to the specified value. Returns greater than zero if the identifier part is greater than the specified value.

Exceptions

Exception Condition
ArgumentNullException

The typeName and/or propertyName parameter is null.

Remarks

This method should use the same comparison rules as the data source to ensure the correct sorting of objects on the client side.

The base implementation of this method uses the default .NET object comparer (Comparer) when the first value implements IComparable; otherwise it calls the IComparable implementation's override Equals method and returns 1 if this returns false.

Permissions

See Also

Reference

DataObjectItemComparer Class

DataObjectItemComparer Members

Compare Overload

Microsoft.VisualStudio.Data Namespace