Enable nullable field backing properties for value types #9445
Replies: 2 comments 2 replies
-
It would have to be some other attribute or marker, since the existing code already has meaning and it would be a breaking change to change memory layouts based on changing the language version. Also, |
Beta Was this translation helpful? Give feedback.
-
An alternative is #133, a feature which solves a wider class of issues including this one (e.g. wanting the type public Guid Id
{
Guid? field;
get
{
if (!field.HasValue)
{
field = ComputeIdOrDefault();
}
return field.Value;
}
} Or simplified: public Guid Id { Guid? field; get => field ??= ComputeIdOrDefault(); } |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Please enable the following:
Current
Suggested
Beta Was this translation helpful? Give feedback.
All reactions