record struct
A record declared as a value type, with the same generated members but copied by value and not allocated on the heap.
In more detail
It is declared with record struct, optionally readonly, instead of plain record. It fits small values with no identity, such as readonly record struct Money(decimal Amount, string Currency).
Related terms
- record — A C# type declared with the record keyword for data, for which the compiler generates a constructor, properties, value equality, a readable ToString and with-expression copying.
- struct — A C# value type declared with the struct keyword, copied in full whenever it is assigned or passed.
- value type — A type whose variables hold the data itself, so assigning one to another copies the whole value.
Taught in
- Records, Pattern Matching, and Modern C# — Modern .NET Core, C# & Enterprise Microservices