C# 9.0 has data classes
Quote from dandl on May 21, 2020, 1:58 amNot to be out done by Java records, it looks like the upcoming C# 9.0 is going to have new data classes.
Why? Mainly because struct is too limited for use as a database record. It has no inheritance, copy semantics and requires a null ctor. Great for values, not so great for records.
The data class gives you all the machinery you need for records that behave as immutable values but implemented as a reference type and with the full range of related features. I guess they looked at Java records and decided to do it better.
It also has a number of interesting other features not so relevant here.
Link: https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/.
Not to be out done by Java records, it looks like the upcoming C# 9.0 is going to have new data classes.
Why? Mainly because struct is too limited for use as a database record. It has no inheritance, copy semantics and requires a null ctor. Great for values, not so great for records.
The data class gives you all the machinery you need for records that behave as immutable values but implemented as a reference type and with the full range of related features. I guess they looked at Java records and decided to do it better.
It also has a number of interesting other features not so relevant here.
Link: https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/.