Records
Learn to define and use record types to create immutable data models with built-in value-based equality and concise syntax.
We'll cover the following...
We'll cover the following...
C# applications frequently use data structures to transport data without relying on complex behavior. Developers can use classes or structs for this task, but C# provides the record type specifically for this purpose.
A record is a reference type that provides built-in functionality for encapsulating data. Unlike standard classes, records are designed to be immutable and focus on value-based equality rather than reference equality.
Positional syntax
Positional syntax is the most common way to define a record. This syntax declares the properties and the primary constructor on a single line.