
Untitled
By: a guest on
Jul 15th, 2012 | syntax:
None | size: 0.91 KB | hits: 10 | expires: Never
VB.Net - Inheritance - can parent and child both have ToString methods? Can both be accessed / used?
Public MustInherit Class MyBaseClass
Public Property Name as String
Public Overloads Function ToString() as String
Return Name
End Function
End Class
Public Class ChildClass
Inherits MyBaseClass
Public Sub New()
Name = "This is the name"
End Sub
public Overloads Function ToString() as string
' Is it possible to call my base class ToString and append the text to
' this ToString method? I realize I can simply access my Name property
' however this does not fulfill the requirements i was given
return "Some text"
End Function
End Class
dim someObject as new ChildClass("Hello VB.Net ")
lblLabel.text = someObject.ToString()
public Overloads Function ToString() as string
return MyBase.ToString() + "Some text"
End Function