I have a DateTime variable that can either be null or a Datetime. I figured a nullable DateTime type would work, but I am getting an error telling me that said
There are multiple ways to resolve this error.
Use Convert.ToDateTime() method which handles null datetime values.
Convert.ToDateTime()
Convert.ToDateTime(lastInvite).AddDays(7);
Use Value property
Value
lastInvite.Value.AddDays(7)
Use GetValueOrDefault() method
GetValueOrDefault()
lastInvite.GetValueOrDefault().AddDays(7)