Mega Code Archive

 
Categories / C# / Date Time
 

Gets the days between

using System; public class MainClass{         /// <summary>         /// Gets the days between.         /// </summary>         /// <param name="first">The first.</param>         /// <param name="last">The last.</param>         /// <param name="inclusive">if set to <c>true</c> [inclusive].</param>         /// <returns></returns>         public static int GetDaysBetween(DateTime first, DateTime last, bool inclusive)         {             TimeSpan span = last - first;             return inclusive ? span.Days + 1 : span.Days;         } }