我有这样的课
public class MyClass
{
public int Id { get; set; }
public Nullable<DateTime> ApplicationDate { get; set; }
....
}
现在我正在尝试填充这样的MyClass
对象
DataTable dt = DBHelper.GetDataTable(sql, conn);
DataRow dr = dt.Rows[0];
MyClass oMyClass = new MyClass();
oMyClass.Id = (int)dr["Id"];
oMyClass.ApplicationDate = dr["ApplDate"] == DBNull.Value ? null : Convert.ToDateTime(dr["AppDate"]);
//Above line gives an error
....
分配应用程序日期值会出错
Type of conditional expression cannot be determined because there is no implicit conversion between '<null>' and 'System.DateTime'
我在这里想念什么?