Code for getting the total number of days between two dates in C#

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 1334
The below code will do so

using System;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
DateTime fromDate = Convert.ToDateTime("3/17/2016");
DateTime ToDate = Convert.ToDateTime("3/21/2016");
var totalDays= (ToDate - fromDate).TotalDays+1;
}
}
}

Comments or Responses

Login to post response