How can we acheive inheritance in VB.NET
How can we acheive inheritance in VB.NET ?
Inheritance is achieved by using Inherits keyword in VB.NET (For C# it is :). Simple Sample is provided in CD for understanding inheritance in folder WindowsApplicationInheritance. There are two classes one is the parent ClsParent and second is the child ClsChild. 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 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
Above is the source which parses only @ of strData variable. 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 characters of the data.
Note:- Strdata was accessible only because it was defined as protected in the parent class.
2007-10-23, 4759👍, 0💬
How do you estimate maintenance project and change requests?
What does static variable mean? There are 3 main uses for static variables: If you declare within a ...
What is AL.EXE and RESGEN.EXE? In the previous question you have seen how we can use resource files ...
How do we get the current culture of the environment in windows and ASP.NET?
What is Traceability Matrix? Traceability Matrix is one of the document will prepare by QA.To make s...