Constructors’ Inheritance

The previous section discussed the MyBase keyword and how it can be used to access members from a base class. The keyword also has another important purpose, which is about constructors. Consider the following constructor that is implemented within the Person class (that is, the base class) shown in the previous section:

image

The problem now is in derived classes. The rule is that if you have a constructor receiving arguments in the base class, you do need to provide a constructor receiving arguments also within a derived class, and the constructor needs to invoke the base class. The following code shows how a constructor ...

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.