L
Louis Somers
Is it possible (if so how) to override the constructor in an abstract class?
Here is a simplified example of what I'm rtying to do:
Create a windows App, drop a button on the form and doubleclick it.
In the onClick event I have:
Button1.Text = New HelloJohn("Hi").ToString()
'should print "Hi John"
Paste the following under the event handler:
Private Class HelloJohn
Inherits HelloWorld
Public Overrides Sub SetName()
_name = "John"
End Sub
End Class
Private MustInherit Class HelloWorld
Protected _greeting As String
Protected _name As String = "world"
Public Sub New()
_greeting = "hello"
SetName()
End Sub
Public Sub New(ByVal Greeting As String)
_greeting = Greeting
SetName()
End Sub
Public MustOverride Sub SetName()
Public Overrides Function ToString() As String
Return _greeting & " " & _name
End Function
End Class
End Class
In this case I'm using a nested class but I tried it on a public class
(in the same namespace) with the same results.
Any Ideas?
Thanks in advance,
Louis
Here is a simplified example of what I'm rtying to do:
Create a windows App, drop a button on the form and doubleclick it.
In the onClick event I have:
Button1.Text = New HelloJohn("Hi").ToString()
'should print "Hi John"
Paste the following under the event handler:
Private Class HelloJohn
Inherits HelloWorld
Public Overrides Sub SetName()
_name = "John"
End Sub
End Class
Private MustInherit Class HelloWorld
Protected _greeting As String
Protected _name As String = "world"
Public Sub New()
_greeting = "hello"
SetName()
End Sub
Public Sub New(ByVal Greeting As String)
_greeting = Greeting
SetName()
End Sub
Public MustOverride Sub SetName()
Public Overrides Function ToString() As String
Return _greeting & " " & _name
End Function
End Class
End Class
In this case I'm using a nested class but I tried it on a public class
(in the same namespace) with the same results.
Any Ideas?
Thanks in advance,
Louis