C# syntax quiz [modified*2]
The Lounge
22
Posts
6
Posters
0
Views
1
Watching
-
Daniel Grunwald wrote:
i =+ +j;
What's that? It's not +=
"i =+ +j;" is the same as "i = +(+j);" - it's using the unary plus operator two times.
-
It's easy with unary plus/minus <-> increment/decrement:
i =+ +j;
x = y - -5 ;But there is another solution that's much more difficult to find:
object o = null;
string text = o is int ? ? "o is Nullable" : "o is not Nullable";Removing the space between the question marks causes them to become the null-coalescing operator ??, and you get a syntax error at the ':'.
Just goes to show that one should always give one's operators room to breathe.