Replies: 1 comment
-
A thought I had while reading the related discussion on the C# Discord, was it considered to have the field initialization be explicit to avoid the ambiguity? IE: record struct Rec(int Item)
{
public int Item { get; set => value < 0 ? throw new Exception() : field = value; field = Item; }
} It's not quite as terse, but I think it makes it more obvious you're assigning the field rather than invoking the setter. Should the team ever chose to pursue them, I think this would also evolve more elegantly towards property-scoped fields and/or having a different type for the backing field. (Assuming it doesn't create a parsing nightmare.) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-03-02.md
Agenda
field
Beta Was this translation helpful? Give feedback.
All reactions