- Class & Object
1. 🔹 What is a Class and Object in C#?
✅ Answer: A class is a blueprint for creating objects. An object is an instance of a class.
💻 Code Example:
Tags:
c#
✅ Answer: A class is a blueprint for creating objects. An object is an instance of a class.
💻 Code Example:
public class Car
{
public string Brand;
public void Drive()
{
Console.WriteLine($"{Brand} is driving");
}
}
Car myCar = new Car();
myCar.Brand = "BMW";
myCar.Drive(); // Output: BMW is driving