M
Michele
I can't why the execution of this code returns this output: Person -
Employee Since the type class of e1 is 'employee', I wonder why the compiler
doesn't call the second method of the Test class. I hope someone can help.
Thank you very much.Public Class Person
Overridable ReadOnly Property name() As String
Get
Return "Person"
End Get
End Property
End Class
Public Class Employee
Inherits Person
Overrides ReadOnly Property name() As String
Get
Return "Employee"
End Get
End Property
End Class
Public Class Test
Public Overloads Shared Function print(ByVal p1 As Person)
Return "Person - " & p1.name
End Function
Public Overloads Shared Function print(ByVal p1 As Employee)
Return "Employee - " & p1.name
End Function
End Class
Module ModuleTest
Sub Main()
Dim e1 As Person = New Employee
Console.WriteLine(e1.name)
End Sub
End Module
Employee Since the type class of e1 is 'employee', I wonder why the compiler
doesn't call the second method of the Test class. I hope someone can help.
Thank you very much.Public Class Person
Overridable ReadOnly Property name() As String
Get
Return "Person"
End Get
End Property
End Class
Public Class Employee
Inherits Person
Overrides ReadOnly Property name() As String
Get
Return "Employee"
End Get
End Property
End Class
Public Class Test
Public Overloads Shared Function print(ByVal p1 As Person)
Return "Person - " & p1.name
End Function
Public Overloads Shared Function print(ByVal p1 As Employee)
Return "Employee - " & p1.name
End Function
End Class
Module ModuleTest
Sub Main()
Dim e1 As Person = New Employee
Console.WriteLine(e1.name)
End Sub
End Module