MyClass Keyword

Another way for accessing base classes’ members is the MyClass keyword. Imagine you have a base class exposing some overridable members, such as properties or methods; then you have a derived class that overrides those members. The MyClass keyword avoids the application of overriding and invokes members on the derived class as if they were NotOverridable on the base class. In other words, MyClass enables executing members of a base class in the context of a derived class, ensuring that the member version is the one in the base class. Listing 12.1 shows an example.

Listing 12.1 Demonstrating the MyClass Keyword

image

The BaseClassDemo ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.