Skip to main content
CSharpUniversity ASP.NET and C# lessons

The search runs entirely in your browser over the published lesson list.

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.

New lessons by email

Leave your address and get a short note whenever a fresh lesson is published. No account needed and you can stop at any time.

Thank you. Your address has been noted in this browser session. Connect a mailing service to deliver the notes for real.