📅  最后修改于: 2022-03-11 14:48:38.659000             🧑  作者: Mango
public static int GetMonthDifference(DateTime startDate, DateTime endDate)
{
int monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}