C# 14 · Records, classes and pattern matching

Customize an auto-property

C# 14: use the field keyword to reach the compiler-generated backing field.

public string Name
{
    get;
    set => field = value.Trim();
} = "";

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?