Null-conditional operator on foreach statements #8261
Replies: 1 comment
-
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.
-
I'd like to propose some syntax candy. Today, it's not uncommon to remedy the warning that a collection might be null with the following:
Just as the null-conditional operator is usually placed after the variable name and before a period indicating access to a member, I would like to propose the following syntax to have identical behavior to the above and save a few lines:
Just as I might use
myEntity?.Property
to retrieve the value ofProperty
whenmyEntity
is not null, so too I place the?
to have the compiler insert the count check as a double savings:Thanks for the consideration!
Beta Was this translation helpful? Give feedback.
All reactions