I can write:
_myVariable?.SetValue(5);
It will call SetValue
only if _myVariable
is not null, fine.
How can I do the same thing with a Property ? Like (caution, this syntax does not exists):
_myVariable?.Value = 5;
Since it does not exists (please contradict me), I have to use that good old if
syntax :
if (_myVariable is not null) _myVariable.Value = 5;
Property setters and Set functions are, in fact, the same thing except syntax, so I feel upset about this difference.
Do you have any syntax in mind better than good old if
?