Since true
is not a string type, how is null + true
a string ?
string s = true; //Cannot implicitly convert type 'bool' to 'string'
bool b = null + true; //Cannot implicitly convert type 'string' to 'bool'
What is the reason behind this?
Since true
is not a string type, how is null + true
a string ?
string s = true; //Cannot implicitly convert type 'bool' to 'string'
bool b = null + true; //Cannot implicitly convert type 'string' to 'bool'
What is the reason behind this?
Interestingly, using Reflector to inspect what is generated, the following code:
is transformed into this by the compiler:
The reasoning behind this "optimization" is a bit weird I must say, and does not rhyme with the operator selection I would expect.
Also, the following code:
is transformed into
where
string b = true;
is actually not accepted by the compiler.