What prints this program?
static void Main(string[] args)
{
int? other = null;
int value = 100 + other ?? 0;
Console.WriteLine(value);
}
I know that I just don't have the language specifications in my head. But it is still surprising that it prints 0 instead of 100. Is there any reasonable explanation for this strange behavior?
When I use curly braces, I get the correct result.
static void Main(string[] args)
{
int? other = null;
int value = 100 + (other ?? 0);
Console.WriteLine(value);
}
source
share