Abstract Class in VB.NET
What is an Abstract Class in VB.NET?
Abstract Class in vb.net 2008Abstract Classes in VB.net
are classes that cannot be instantiated, but can implement any number of members. The
Abstract Classes are declared using the keyword MustInherit
. Overideable members should be declared inside the
abstract class using the keyword MustOverride
that are instantiated in the derived class by overriding them.
Public MustInherit Class student
Public id As Integer
Public Function Add() As Integer
Dim i, j As Integer
i = 100
j = 200
Console.WriteLine("Result:" & (i + j))
Public MustOverride Sub Disp()
Public Overrides Sub Disp()
Console.WriteLine("Instantiating the abstract member
function disp() in the derived class.")
Dim obj As New Shed
Instantiating the abstract member function disp()
in the derived class
In the above example, the Absract class 'student'
acts as a base class and the abstract member
of the class 'Disp()'
is overidden inside the derived class Shed