C#

Microsoft's object-oriented language and the foundation of the whole .NET ecosystem.

ProficientProgramming languages3 min read

C# is the language I have spent most of my career in. These are the notes I keep coming back to — the parts that bite, not the tutorial.

The split between value and reference types explains most surprises in C#.

// record: reference type, value equality, immutable by default
public record User(string Name, string Email);

// record struct: value type with the same equality semantics
public readonly record struct Money(decimal Amount, string Currency);

var a = new User("Ada", "ada@example.com");
var b = new User("Ada", "ada@example.com");
Console.WriteLine(a == b); // True — records compare by value

Nullable reference types turn "this could be null" into something the compiler checks. They are a compile-time promise, not a runtime guarantee: data coming from JSON or a database can still arrive null.

#nullable enable
string? maybe = null;   // allowed
string sure = maybe;    // warning CS8600