i have a table provider with column
implied(tiny int)(something like nullable bool)
providerid(int)
I have a form and i have check box
I am doing winforms applications using c# ..
i am using enitities and my dbcontext name is dbcontext
How to covert bool to nullable bool(bool?) in C sharp.
I have tried this way
if (chkbox.checked == true)
bool yes = 0;
else
bool yes = 1;
dbcontext.implied = yes;
but got an error
Cannot convert bool to bool?
Explicitly cast to a
bool?In case it’s of interest, you can convert
bool?tobool. You can do this by first checkingHasValuewhich will returnfalseif it’s null ortrueif it is not null.If it does have a value, you can cast to a bool.
Check out http://msdn.microsoft.com/en-us/library/bb384091.aspx for bool? to bool conversion.