Back to course

Classes and Objects: The Foundation of OOP

.NET Zero to Hero: Master C# and Modern App Development

Intro to Object-Oriented Programming (OOP)

C# is an object-oriented language. A Class is a blueprint (like a drawing of a car), and an Object is an instance of that blueprint (the actual car).

Example Class:

csharp class Car { public string color = "red"; public int maxSpeed = 200; }

Creating an Object:

csharp Car myObj = new Car(); Console.WriteLine(myObj.color);

public is an access modifier, meaning it's accessible from outside the class.