Call constructor from MustInherit Class : Inherits « Class Module « VB.Net Tutorial






Imports System

  Module HelloWorld
    Public Sub Main()
      Dim hs as New Person("A","B")
      Console.WriteLine(hs.FirstName & "." & hs.LastName)
    End Sub
  End Module
  
  Public MustInherit Class Abstract
    Public FirstName, LastName as String
    Public Sub New(ByVal FirstName as String, ByVal LastName as String)
      Me.FirstName = FirstName
      Me.LastName = LastName
    End Sub  
    Public MustOverride Function GetFullName as String  
  End Class
  
  Public Class Person
    Inherits Abstract
    Public Sub New(ByVal FirstName as String, ByVal LastName as String)
      MyBase.New(FirstName,LastName)
    End Sub
    Public Overrides Function GetFullName as String
      GetFullName = FirstName & "." & LastName
    End Function
  End Class








6.16.Inherits
6.16.1.'Inherits' must be first line. There can be only one
6.16.2.Call constructor from MustInherit Class