StringComparer: Equals

Equals

Compares two values for equality.



 Public Function Equals(
	  ByRef x As Variant,
	  ByRef y As Variant ) As Boolean

Parameters

x
[ByRef] Variant. A value to be compared for equality.
y
[ByRef] Variant. A value to be compared for equality.

Return Values

Boolean -  Returns true if x and y are equal; otherwise false.

Remarks

When implementing this method, any custom logic should be applied to only type String. All other value types should be passed to the default comparer for consistent behavior.

The example is the implementation used by the StringComparer.Ordinal and StringComparer.OrdinalIgnoreCase implementation.

    Private mStringComparison As StringComparison

    Private Function StringComparer_Equals(x As Variant, y As Variant) As Boolean
        If VarType(x) = vbString Then
            If VarType(y) = vbString Then
                StringComparer_Equals = CorString.Equals(x, y, mStringComparison)
                Exit Function
            End If
        End If

        StringComparer_Equals = Object.Equals(x, y)
    End Function
 

See Also

Project CorLib Overview

Class StringComparer Overview