C# 14 · Records, classes and pattern matching

Declare an immutable data type

A record gives you value equality, ToString and deconstruction.

public record Person(string Name, int Age);

var ada = new Person("Ada", 36);

Official C# 14 documentation

More records, classes and pattern matching commands

All records, classes and pattern matching commands · C# 14 cheatsheet

Was this page helpful?