In order to modify the definition of the base class at the derived class then the method should be prefixed with the “Overrides” keyword.
If any method is defined using the “Overrides” keyword at the derived class then the method should be prefixed with the “Overridable” keyword at the base class.
If any method is prefixed with the “Overridable” keyword at the base class then it is not mandatory to redefine the definitions at the derived class.
‘‘Demo on Method Overriding
Imports system
Module Method Overriding ‘‘Demo
Class Parents
Public Overridable sub-MyProperty ( )
Console.WriteLine (“Use property for business”)
End sub
End class
Class Children overrides sub-MyProperty ( )
MyBase.My property ( ) invokes the base class my property method
Console.WriteLine (“Use the property for charity”)
End sub
End class
Sub main ( )
Dim c as New Children
C.MyProperty ( )
End sub
End Module
Inclined to build a profession as VB.Net Developer? Then here is the blog post on, explore VB.Net Training
It is used to maintain two definitions at the derived class such that one definition can be shadowed in order to project the other definition i.e., the definition of the base class can be shadowed in order to project the new definition provided at the derived class and vice versa is also applicable.
‘‘Demo on Shadowing
Imports system
Module Shadowing ‘‘Demo
Class Parents Public sub-MyProperty ( )
Console.WriteLine (“Use the property for business”)
End sub
End class
Class children
Inherits Parents
Public Shadows sub-MyProperty ()
Console.WriteLine (“Use property for charity”)
End sub
End class
Sub main ( )
Dim c as New Children
C.MyProperty ( )
Dim P as Parents
P.MyProperty ( )
End sub
End Module
You liked the article?
Like: 0
Vote for difficulty
Current difficulty (Avg): Medium
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.