'Shadows' vs. 'Overrides' in VB.NET

Jeff picture Jeff · Jan 20, 2009 · Viewed 67.1k times · Source

What is the significance of the two keywords Shadows and Overrides? What they do and for which context is one or the other preferable?

Answer

Nick picture Nick · Feb 4, 2009

Overrides is the more normal qualifier. If the child class redefines a base class function in this way, then regardless of how a child object is referenced (using either a base class or a child class reference) it is the child function that is called.

On the other hand, if the child class function Shadows the base class function, then a child object accessed via a base class reference will use that base class function, despite being a child object.
The child function definition is only used if the child object is accessed using a matching child reference.