Why is this code invalid in C#?
- by mmattax
The following code will not compile:
string foo = "bar";
Object o = foo == null ? DBNull.Value : foo;
I get: Error 1 Type of conditional expression cannot be determined because there is no implicit conversion between 'System.DBNull' and 'string'
To fix this, I must do something like this:
string foo = "bar";
Object o = foo == null ?…