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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.