public class MustOverrideMustInherit
public Shared Sub Main
Dim Emp1 As New Employee()
Emp1.Name = "B"
Console.WriteLine(GetName(Emp1))
Dim Cus1 As New Customer()
Cus1.Name = "T"
Console.WriteLine(GetName(Cus1))
End Sub
Public Shared Function GetName(ByVal p As Person) As String
Return p.Name
End Function
End class
Public MustInherit Class Person
Public MustOverride Property Name() As String
End Class
Public Class Employee
Inherits Person
Private m_Name
Public Overrides Property Name() As String
Get
Return m_Name
End Get
Set(ByVal Value As String)
m_Name = Value
End Set
End Property
End Class
Public Class Customer
Inherits Person
Private m_Name
Public Overrides Property Name() As String
Get
Return m_Name
End Get
Set(ByVal Value As String)
m_Name = Value
End Set
End Property
End Class
|