DateTime tempDate = calculatesomedatetime();
someDateTimeControl.Value = null; //no issue
someDateTimeControl.Value = (tempDate > DateTime.MinValue)? tempDate : null;
Type of conditional expression cannot be determined because there is no implicit conversion between System.DateTime and null
(tempDate > DateTime.MinValue)
null
if(tempDate > DateTime.MinValue)
{
someDateTimeControl.Value = tempDate;
}else
{
someDateTimeControl.Value = null;
}
The issue is with the ternary operation. You're changing the data type from DateTime to a nullable DateTime. Ternary operations require you to return the same data type both before and after the colon. Doing something like this would work:
someDateTimeControl.Value = (tempDate > DateTime.MinValue) ? (DateTime?)tempDate : null;