I am trying to set int? to null
or to the dateTime.Year or a TimeSpan. I am checking if the dt is equal to the default datetime. Then setting the int? to null or a calculated value. Is this the correct way to do this?
DateTime? dtnull = null;
DateTime? dt = new DateTime(2023, 09,27,00,00,00);
DateTime currentDateTime = DateTime.Now;
int? RemainingDaysnull = (dtnull == default(DateTime)) ? null : (dtnull.Value - currentDateTime).Days;
int? Last4EndDatenull = (dtnull == default(DateTime)) ? null(dtnull.Value).Year;
int? RemainingDays = (dt == default(DateTime)) ? null : (dt - currentDateTime).Days;
int? Last4EndDate = (dt == default(DateTime)) ? null : (dt.Value).Year();