This is the most obvious use for a Nullable<bool>
Your βobviousβ behavior leads to many non-obvious behavior.
If
if(x)
treated as false, when x is null, then what should happen to
if(!x)
? !x also null when x is null, and therefore it will also be considered false! Does it not seem strange to you that you cannot reverse the behavior of a conditional with inversion?
What about
if (x | !x)
Of course, this should always be true, but if x is null, then the whole expression is null and therefore false.
It is better to avoid these unobvious situations by simply making them illegal. C # - "make the user say what they mean unambiguously."
I believe VB has the behavior you want. You might consider switching to VB if that is what you like.
source share