Classes and Objects in C#
Introduction
In this lesson, you will learn classes and objects in C# for beginners. These are the foundation of object-oriented programming and are used in almost every real-world application.
What is a Class?
A class is a blueprint used to create objects. It defines properties and methods.
class Student
{
public string name;
public int age;
}
What is an Object?
An object is an instance of a class. It is used to access class data and methods.
Student s1 = new Student();
s1.name = "Rahul";
s1.age = 20;
Console.WriteLine(s1.name);
Console.WriteLine(s1.age);
Class with Method
class Student
{
public string name;
public void ShowName()
{
Console.WriteLine(name);
}
}
Student s1 = new Student();
s1.name = "Amit";
s1.ShowName();
Real-World Use
- Student management system
- Banking system
- E-commerce applications
Key Points
- Class is a blueprint
- Object is an instance of class
- Used to structure programs
Internal Link
- Course Page: .NET Course for Beginners



