int monthCount = GetMonthCount(comp.PaymentFrequency);
int day = comp.MaturityDate.GetValueOrDefault(DateTime.Today).Day;
DateTime countFrom = comp.EffectiveDate.GetValueOrDefault(DateTime.Today);
return new DateTime(countFrom.Year, countFrom.Month, day).AddMonths(monthCount);
Run Code Online (Sandbox Code Playgroud)
年,月和日参数描述了无法代表的日期时间?为什么?