这是设置可为空的DateTime的最佳方法吗?对于我有今天或明天的订购日期的对象,则设置一个日期,否则我需要将其设置为空。
code:
var order = new OrderSetup
{
Customer = Customer,
Total = Total,
OrderDate = string.Compare(OrderStatus, "Today", StringComparison.OrdinalIgnoreCase) == 0 ?
Dates.TodayOrderDate :
string.Compare(OrderStatus, "Tomorrow", StringComparison.OrdinalIgnoreCase) == 0 ?
Dates.TommorrowOrderDate : (DateTime?)null //is this the best way where it seems like I have to set this as a nullable datetime.
};