There is a lot of syntax sugar with Nullable<T>
like those:
int? parsed to Nullable<int>
int? x = null
if (x != null) // Parsed to if (x.HasValue)
x = 56; // Parsed to x.Value = 56;
And more.
Why if
condition with Nullable doesn't work?
if (x)
{}
It gets Complier error saying can't convert Nullable<bool>
to bool
.
Why it's not being parsed to if (x.HasValue && x.Value == true)
or something similar?
It's the most obvious usage for Nullable<bool>