We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi guys! Since we've null-conditional operator, why we cannot have a null-conditional assignment, like:
string var1 = "value1"; string var2 = null; var1 ?= var2;` Assert.AreEqual("value1", var1);
You may say that I can write the same thing using
string var1 = "value1"; string var2 = null; var1 = var2 ?? var1;
but here I'm setting var1 to var1 even if not necessary. With null-conditional assignment the compiler produce this code:
string var1 = "value1"; string var2 = null; if (var2 != null) var1 = var2;
With null-conditional operator instead:
string var1 = "value1"; string var2 = null; var1 = (var2 != null) ? var2 : var1;
What do you think?
The text was updated successfully, but these errors were encountered:
Dupe of #10249, #9529, #8894, #5163, #3366 and #205.
The resolution of #205 was "won't fix", so I don't think that the operator is under consideration.
Sorry, something went wrong.
ops, sorry :-(
No branches or pull requests
Hi guys!
Since we've null-conditional operator, why we cannot have a null-conditional assignment, like:
You may say that I can write the same thing using
but here I'm setting var1 to var1 even if not necessary.
With null-conditional assignment the compiler produce this code:
With null-conditional operator instead:
What do you think?
The text was updated successfully, but these errors were encountered: