Shadowing of Class Procedures

Visual Basic also provides another way of replacing procedures in a base class with others of the same name in a derived class. This is called member shadowing.

After defining a function in a base class, a function of the same name in a derived class can completely shadow the original, as shown in the following example:

Companion Content

Open the corresponding solution (.sln), which you can find in the \VB 2010 Developer Handbook\Chapter 10\Shadowing01 folder.

Module mdlMain Sub Main() Dim locBaseInstance As New BaseClass Console.WriteLine(locBaseInstance.AFunction().ToString()) locBaseInstance = New DerivedClass Console.WriteLine(locBaseInstance.AFunction().ToString()) Console.WriteLine() Console.WriteLine("Press key ...

Get Microsoft® Visual Basic® 2010 Developer’s Handbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.