3 ms·
I asked the .NET Core team this yesterday during one of the Build talks, appearently data records can be defined as either class or struct and take on the same
by joshschreuder 6y ago
I asked the .NET Core team this yesterday during one of the Build talks, appearently data records can be defined as either class or struct and take on the same heap/stack allocation semantics as a regular class or struct.
My understanding is that structs are not always a good choice depending on the size of the data contained within because they are put on the stack, so having an immutable class record does not necessarily overlap with the use cases for structs.
It seems like records are more of a syntactic sugar which gives you a number of pre-defined behaviours such as value comparison and immutability by default (vs. regular classes).