Ternary operators don’t work with nullable value types?

By Charlotte

I’ve got the following situation: DateTime? myDt = (DateTime) row[“Column”]; This fails when retrieving a DBNull value, so we check for that: DateTime? myDT = (row[“Column”] == DBNull.Value) ? null : (DateTime) row[“Column”]; This won’t compile, however doing: DateTime? myDT; if(row[“Column”] == DBNull.Value) myDT = null; else myDT = row[“Column”]; works fine, now, I realise…