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();
} = "";
More records, classes and pattern matching commands
- Declare an immutable data type
- Copy a record with changes
- Declare a class with a primary constructor
- Require properties at creation
- Choose a value with a switch expression
- Test and unpack a type
All records, classes and pattern matching commands · C# 14 cheatsheet