The total months. - CSharp System

CSharp examples for System:DateTime Month

Description

The total months.

Demo Code

// Copyright by the Spark Development Network
using System;// w  w  w.  j  a va 2s.com

public class Main{
        /// <summary>
        /// The total months.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        /// <returns></returns>
        public static int TotalMonths( this DateTime end, DateTime start )
        {
            return ( end.Year * 12 + end.Month ) - ( start.Year * 12 + start.Month );
        }
}

Related Tutorials