VB.Net Tutorial/Class Module/ToString
Override ToString method
Option Strict On
Imports System
Public Class Dog
Private weight As Integer
Public Sub New(ByVal weight As Integer)
Me.weight = weight
End Sub
Public Overrides Function ToString( ) As String
Return weight.ToString( )
End Function
End Class
Public Class Tester
Shared Sub Main( )
Dim i As Integer = 5
Console.WriteLine(i.ToString( ))
Dim milo As New Dog(62)
Console.WriteLine(milo.ToString( ))
End Sub
End Class
5 62