ObjectBase: Equals

Equals

Default object comparison. Simply checks for reference to same instance.



 Public Function Equals(
	  ByVal ObjA As IObject,
	  ByRef ObjB As Variant ) As Boolean

Parameters

ObjA
[ByVal] IObject. The subclass requesting the call.
ObjB
[ByRef] Variant. The value to be equating the subclass to.

Return Values

Boolean -  True if both values point to the same object instance; False otherwise.

Remarks

The implementer of the IObject interface can use this method as the default behavior, or create custom behavior using their own logic.

Examples

This example shows the typical implementation of the IObject interface using the MyBase methods for default behavior.

Option Explicit
Implements IObject


Public Function Equals(ByRef Value As Variant) As Boolean
    Equals = MyBase.Equals(Me, Value)
End Function

Public Function GetHashCode() As Long
    GetHashCode = MyBase.GetHashCode(Me)
End Function

Public Function ToString() As String
    ToString = MyBase.ToString(Me, App)
End Function


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'   IObject
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function IObject_Equals(Value As Variant) As Boolean
    IObject_Equals = Equals(Value)
End Function

Private Function IObject_GetHashCode() As Long
    IObject_GetHashCode = GetHashCode
End Function

Private Function IObject_ToString() As String
    IObject_ToString = ToString
End Function

See Also

Project CorLib Overview

Class ObjectBase Overview