![]() if a is null then assign 0 to a and add a to the listĬonsole.WriteLine((a is null)) // expected: falseĬonsole.WriteLine(string.Join(" ", numbers)) // output: 5 0 Then, add 5 to numbersĬonsole.WriteLine(string.Join(" ", numbers)) // output: 5Ĭonsole.WriteLine((numbers is null)) // expected: falseĬonsole.WriteLine((a is null)) // expected: trueĬonsole.WriteLine((a ? 3)) // expected: 3 since a is still null List numbers = null Ĭonsole.WriteLine((numbers is null)) // expected: true ![]() The ?= operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-null. The null-coalescing assignment operator ?= assigns the value of its right-hand operand to its left-hand operand only if the left-hand operand evaluates to null. The ? operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-null. ![]() ![]() The null-coalescing operator ? returns the value of its left-hand operand if it isn't null otherwise, it evaluates the right-hand operand and returns its result. ![]()
0 Comments
Leave a Reply. |