¿Cómo puedo restar dos fechas cuando una de ellas puede contener nulos?TimeSpan usando una fecha que se puede anular
public static int NumberOfWeeksOnPlan(User user)
{
DateTime? planStartDate = user.PlanStartDate; // user.PlanStartDate is: DateTime?
TimeSpan weeksOnPlanSpan;
if (planStartDate.HasValue)
weeksOnPlanSpan = DateTime.Now.Subtract(planStartDate); // This line is the problem.
return weeksOnPlanSpan == null ? 0 : weeksOnPlanSpan.Days/7;
}