I'm having one null-able bool (bool?
) variable, it holds a value null. One more variable of type pure bool
, I tried to convert the null-able bool to bool. But I faced an error "Nullable object must have a value."
My C# Code is
bool? x = (bool?) null;
bool y = (bool)x;
null
...it has nobool
value to be cast to - if you'd like the default value for the type to be assigned ifx
is null, use theGetValueOrDefault()
method. – Almanza