"Record With Statement Example"

var user = new User("Ben", 30);
user = user with { Age = 31 };
Console.WriteLine(user); // User { Name = Ben, Age = 31 }


Code snippet taken from "Two Decades of C#: A Reference - C# 9".