Overloading Constructors
Because constructors are effectively methods, they support the overloading feature. You can therefore provide multiple implementations of the New
method, taking care of the limitations described for methods. You cannot use the Overloads
keyword; the compiler does not need it. For example, continuing the example of the Contact
class, we can provide different implementations of the constructor as follows:
The first overload receives no arguments and provides a default members’ initialization. The second overload receives just an argument, initializing other members with empty strings. The last overload is the most complete ...
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.