Learn to program in Visual Basic .NET, the right way

Classes - Constructor

What is a Constructor?

Simply put, a Constructor is the method that gets executed when a Class is created.

A Constructor is a Sub Routine named New, as demonstrated in the following example:

Fiddle: Live Demo

Overloading

A Class may have zero or more Constructors, however if there is more than one Constructor then the method signatures must be unique.

The following demonstrates a Class with multiple Constructors:

Fiddle: Live Demo

Remarks

While a Constructor is not required when creating a Class, one would be automatically be created behind the scenes if it omitted.