UTF8Encoding: ToString

ToString

Returns a string representation of the current object.



 Public Function ToString ( ) As String

Return Values

String -  A string representation of the current object.

Remarks

ToString is the major formatting method in VBCorLib. It converts an object to its string representation so that it is suitable for display.

A default implementation of the ToString method would be to call the MyBase.ToString method as the following example shows.

Implements IObject

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


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'   IObject Implementation
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function IObject_ToString() As String
    IObject_ToString = ToString
End Function

Types commonly implement the ToString method to return a string that represents the object instance. For example, the types such as CorDateTime, and StringBuilder provide ToString implementations that return the string form of the value that the object represents. The following example defines a class, Class2, that customizes the ToString method to return the type name along with its value.

Implements IObject

Public Value As Variant


Public Function ToString() As String
    ToString = MyBase.ToString(Me, App) & ": " & Object.ToString(Value)
End Function


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'   IObject Implementation
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function IObject_ToString() As String
    IObject_ToString = ToString
End Function

See Also

Project CorLib Overview

Class UTF8Encoding Overview