From the course: Visual Basic Essential Training

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Create a constructor

Create a constructor

- [Instructor] When we instantiate a new object with the new keyword, that object is created and added to the application memory space. That's what we see happening on line 37, using the new keyword to instantiate a card. When the runtime creates the object, it calls the class constructor. The primary purpose of a constructor is to initialize the object by setting up its initial state. This typically involves assigning values to fields, initializing properties, or performing any setup required for the object to function properly. Every class has a constructor. I have three constructors in this card class. I have one here, it's a parameter list constructor, and then I have a second one here that takes two parameters and I have a third one. Press the control shift and then tap the space bar, and that tells IntelliSense to give me some information about the constructor. It shows me there are three versions of it. One that takes no parameters, one that takes two parameters. They're both…

Contents