Can I cast from DBNull to a Nullable Bool in one line?

You could write value as bool?.
This will return null if value is not of type bool.

Note that this is somewhat inefficient.


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"];