Using the null-conditional operator on the left-hand side of an assignment

The null propagation operator returns a value. And since you must have a variable on the left hand side of an assignment, and not a value, you cannot use it in this way.

Sure, you could make things shorter by using the tenary operator, but that, on the other hand, doesn’t really help the readability aspect.

Joachim Isaksson’s comment on your question shows a different approach that should work.

Leave a Comment