MyClass Keyword
Another way of accessing the 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.
Public Class BaseClassDemo Public Overridable ReadOnly Property Test As String Get ...
Get Visual Basic 2015 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.