4
I looked at the documentation of Microsoft but still I found it a bit confusing, the main things I managed to abstract were:
"?." - is a conditional null operator and tests the value of the left operand to null before executing a member access. I found this very confusing
"??" - is a null coalescence operator, it returns the left operand if the operand is not null; otherwise it will return the right operand..
Apparently they present have very similar functions, wanted to know what is the real difference between them.
And why can’t I use them within the condition of a IF
or a WHILE
?
Null coalescence is easier to understand. If the left side is null, return what is on the right side. Example:
string nome = null ?? "jeff";
, what will be the content of the variablenome
?– Jefferson Quesado