Creating objects from your class
A class is the plan. An object is one thing built from that plan. You can build as many as you need, each with its own values.
Create, set, call
C#
Lesson first = new Lesson();
first.Title = "Data types";
first.Minutes = 15;
Lesson second = new Lesson();
second.Title = "Loops";
second.Minutes = 20;
outputLabel.Text = first.Summary() + " / " + second.Summary();What to notice
- Two objects from one class keep their own values.
- The dot operator reaches into an object to read, set or call.
- The same method runs against whichever object you call it on.
Think of it as a noun. The class is the noun, the object is one example of it, and the methods are the verbs it can perform.
Now that objects exist, decide what the outside world is allowed to touch in public and private members.