I have a database query which will either return NULL
or a boolean (bit) value.
I wish to store this value in a variable of type Nullable
assuming you have a datareader dr:
bool? tmp = Convert.IsDBNull(dr["dbnullValue"]) ? null: (bool?) dr["dbnullValue"];
---ADDED----
or maybe you can use the ?? if you don't have to check for DBNull but i'm not sure compiler will like this (i cannot test it now)
bool? tmp = dr["dbnullValue"] ?? (bool?) dr["dbnullValue"];