Skip to the workspace
Pebellslearn by building
C# and .NET Basics  ›  Lesson

C# — The Language You Write

C# 14 minC# is a statically typed, object-oriented language where every value has a type the compiler checks before the program runs.

aspnet core / C# — The Language You Write

Explore each scene at your own pace.

01 · The rule

The rule

C# — The Language You Write

Throughout this course you will build ReadingRoom, a small lending-library API with books, members and loans. Every line of it is C#. Before any web code, you need to read C# comfortably: what a type is, what a class is, and why the compiler rejects code before you ever run it.

The rule

Every value has a type, and the compiler checks it before anything runs.

C# is statically typed. When you declare a variable, its type is fixed. If you try to put the wrong kind of value in it, the build fails — you find the mistake at your desk, not in production.

int copies = 3;              // a whole number
string title = "Dune";       // text
decimal lateFee = 0.50m;     // money: use decimal, not double
bool isOverdue = false;

var year = 1965;             // still an int: var infers, it does not loosen

Types you build yourself are classes and records. A record is a short way to write a type that mostly carries data:

public record Book(int Id, string Title, string Author, int Year);

var book = new Book(1, "Dune", "Frank Herbert", 1965);
Console.WriteLine(book.Title);   // Dune

Modern projects switch on nullable reference types. Then string means "never null" and string? means "might be null", and the compiler warns when you forget to check.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.