The C# 4.0 compiler does not complain about this (not even a warning):
if(10.0 > null + 1)
{
}
if (myDoubleValue > null)
{
}
And it seems to be always false. What is going on here? Is null automatically converted to Nullable<double>
or something?
If so why doesn't this work then:
double myDoubleValue = null + 1;
Also, why would I ever want such a behavior. Why is it a good thing that it is possible playing around with literals like this.