Back to course

Records (C# 9.0 and later)

C# Zero to Hero: Comprehensive Programming Masterclass

Records

Records are a special kind of class that provide built-in functionality for encapsulating data. They are immutable by default.

Example

csharp public record Person(string FirstName, string LastName);

var p1 = new Person("John", "Doe"); // records support value-based equality

Perfect for Data Transfer Objects (DTOs).