3 ms·
Aren't records meant to be immutable? I don't understand why properties have setters in the generated definition of the record. I'm missing something.
by Renaud 6y ago
Aren't records meant to be immutable?
I don't understand why properties have setters in the generated definition of the record. I'm missing something.
- Todd 6y agoConstructor-defined properties of records are implemented using auto-implemented properties with the new init keyword, so: public int MyProp { get; init; } instead of public int MyProp { get; set; } Apparently those are implemented using readonly backing fields while still retaining property setters.