Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How can we acheive inheritance in VB.NET
How can we acheive inheritance in VB.NET ?
✍: Guest
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 character’s of the data.
Note:- Strdata was accessible only because it was defined as protected in the parent class.
2007-10-23, 5567👍, 0💬
Popular Posts:
What is difference between Association, Aggregation and Inheritance relationships? In object oriente...
What is the benefit of using #define to declare a constant? Using the #define method of declaring a ...
How do we configure “WebGarden”? “Web garden” can be configured by using process model settings in...
How To Return the Second 5 Rows? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries If yo...
What are the different elements in Functions points? The different elements in function points are a...