I want to convert a nullable DateTime (DateTime?
) to a DateTime
, but I am getting an error:
Cannot implicitly convert type 'System.DateTime?' to
'System.DateTime'. An explicit conversion exists (are you missing a
cast?)
I have attempted the following:
DateTime UpdatedTime = (DateTime)_objHotelPackageOrder.UpdatedDate == null
? DateTime.Now : _objHotelPackageOrder.UpdatedDate;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…