Skip to content

๐Ÿ’ป Records (C# 9)

public record User(string Name, int Age);
var u1 = new User("Ann", 30);
var u2 = u1 with { Age = 31 }; // non-destructive mutation

Pitfalls: records compare by value; be mindful of with-expressions copying nested references.