Inheritance in VB.NET
How to use Inheritance in VB.NET?
Inheritance in VB.net 2008Inheritance in VB.net
is method by which the properties of the base classes are added to the derived classes.
In Vb.net the keyword Inherits
is used in the derived class to specify its base class.
keyword is used to speciy that class can be used only as a base class,NotInheritable
is used to specify that a class cannot be inherited.
Public Class s1
Public a As Integer = 5
Public Function val() As Integer
Public Class s2
Public c As Integer = 20
Public Function add() As Integer
Return c + a
Dim res As New s2
System.Console.WriteLine("Final Value is::")
Final Value is: 25
In the above example the value of a
is inherited to from base class s1
to the derived class
. Using the instance res
of class s2
the values of 'a' as well as 'c' is added to give the result.