Proposal: single line 'checked;' and 'unchecked;' applying to the rest of the block #9707
Unanswered
epa
asked this question in
Language Ideas
Replies: 0 comments
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.
-
The
checked { ... }
andunchecked { ... }
syntax is easy to use but adds another level of blocks and indentation. A few years ago C# version 8 added an alternative syntax forusing
which applies to the rest of the current block. I suggest something similar:That would be equivalent to
The same rule can handle having more than one
checked;
orunchecked;
inside the same block: each one is equivalent to the old syntax starting a new block.is equivalent to
The proposal #552 for a
checked
modifier on the method itself is perhaps motivated by a similar concern to reduce braces and nesting, but I think this way is simpler and more general.Beta Was this translation helpful? Give feedback.
All reactions