Check out example codes for "compute months c#". It will help you in understanding the concepts better.

Code Example 1

public static int GetMonthDifference(DateTime startDate, DateTime endDate)
{
    int monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
    return Math.Abs(monthsApart);
}

Learn ReactJs, React Native from akashmittal.com