C# Interview Question #12

What is a class in C#?

OOP & Core C# Concepts Junior Beginner

Quick Interview Answer

A class is a blueprint or user-defined reference type used to describe the data and behavior of objects.

Detailed Explanation

A class is a blueprint or user-defined reference type used to describe the data and behavior of objects.

A class can contain fields, properties, methods, constructors, events, nested types, and other members.

The class defines the structure, while individual objects created from the class hold actual runtime data.

Code Example

public class Product
{
    public int Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public decimal Price { get; set; }
}