
C# 9 introduces a new keyword - record. It's a reference type, but with value-based comparison. It makes an object immutable and behave like a value type. The whole object can be immutable if the init keyword is set on each property, if you are using an implicit parameterless constructor.
Record keyword

With expression

Value base comparison

Positional records

Records and inheritance

Value based comparison and inheritance

FAQ about Records
- Are records a value type ?
- Can a Record have a Struct and classical object as properties ?
- Are with expressions available for Structs and classes ?
- Are Records immutable by default ?
No! Records are reference type, they behave like value type (like Structs) for comparison. Like Structs they override Equals virtual method to have “value-based equality”, comparing each field of the struct by calling Equals on them recursively.
Yes it’s definitely possible.
No. It gives a compilation error.
No. They are only acting as value type by default, you have to set all properties with init keyword.