ObjectBase

ObjectBase


This class represent a proxy as a base class for those classes that implement IObject. It is intended to give default behavior for the three main methods of the Object class in .NET. The base class is accessed using the MyBase global static property.

This class is not intended to be used by code other than in the methods of the IObject interface implementations.


Public:

Methods:

NameDescription
 Equals Default object comparison. Simply checks for reference to same instance.  
 GetHashCode Returns a hashcode for the specified object instance.  
 ToString Returns a string representation of the object instance with optional project name.  

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