How inheritance is achieved in VB.NET?
The Inheritance is achieved by using "Inherits" keyword in the VB.NET (& For C# it is ":"). Easy Sample is provided in CD for understanding inheritance in the folder "WindowsApplicationInheritance". There are 2 classes one is the parent "ClsParent" and second is the child "ClsChild". The Parent class has a string which has to parsed for junk data "@" and "/".ClsParent has the functionality which parses only cleans up "@"."ClsChild" then inherits from parent and adds some extra functionality by parsing "/".
Public Class ClsParent
Protected strData As String = "jksdhkj@dadad///ajkdhsjakd"
Public Function Parse() As String
Dim PstrData As String
PstrData = strData PstrData = Replace(PstrData, "@", "")
Return PstrData
End Function
Public Function GetActualString() As String
Return strData
End Function
End Class
Public Class ClsChild
Inherits ClsParent
' this is child and a special parse function is added which will also parse "/"
Public Function ParseBackSlash()
Dim PstrData As String
PstrData = Me.Parse()
PstrData = Replace(PstrData, "/", "")
Return PstrData End Function
End Class
Above is the source code for "ClsChild" which does the remaining work. It adds extra functionality by parsing "/" junk character's of the data.
Figure:-Inheritance in action