Records · TL;DR
1 min readRapid overview
TL;DR
A record (C# 9) is a class or struct where the compiler generates value-based equality (Equals, GetHashCode, ==, !=, IEquatable<T>), a readable ToString, a copy constructor used by with expressions, and, for the positional form, init-only properties plus a Deconstruct method. record / record class is a reference type; record struct (C# 10) is a value type; readonly record struct is an immutable value type. Records are the named, encapsulated counterpart of a tuple: use them for DTOs, messages, events, value objects and API contracts. They are only shallowly immutable, and their equality is only as deep as the equality of their members.