Locked lesson.
About this lesson
We learn how to create our own class and define the attributes within.
Exercise files
Download this lesson’s related exercise files.
44 - Intro To Classes Part 2.docx60.9 KB 44 - Intro To Classes Part 2 SOLUTION.docx
58.9 KB
Quick reference
Intro To Classes (Part 2)
Classes can be created in the Solution Explorer on the right side of the Visual Studio screen.
When to use
Do this every time you want to create a class.
Instructions
{
// Create Book Object
Book book1 = new Book();
book1.title = "C# Programming";
book1.author = "John Elder";
book1.pages = 309;
Console.WriteLine(book1.title);
}
// Create Class
class Book
{
public string title;
public string author;
public int pages;
}
Hints & tips
- Class names start with Capital Letters
- Classes can be created from the Solution Explorer in Visual Studio
Lesson notes are only available for subscribers.