How can one write legally: in C ++ and ??? in c #?

These questions are a kind of game, and I did not find a solution for them.
You can write :::in C ++ without using quotes or something like this, and the compiler will accept it (macros are also forbidden).

And the same is true for C #, but in C # you need to write ???.

I think that C ++ will use the scope operator ::, and C # will use ? :, but I do not know the answers to them.

Any idea?

+5
source share
3 answers

You can write three consecutive question marks in C # without quotes, but not without spaces, using the zero-coalescing operator and the aliases symbol:

object x = 0;
int y = x as int? ?? 1;
+4

:

C++

class A{};
class B : :: A{};

int foo;

int bar(){
    return decision ? -1 : :: foo;
}

( :: :, ).

, Aaronaught ? ?? #, ?? ?, .

+1
I think C# will use ? :

Do you mean the use of three question marks on one line?

var a = true ? new Nullable<int>(1) ?? 1 : 0;

Edit: as far as I know, it is impossible to write ???to any version of C #.

0
source

All Articles