Q:

Write a C# Sharp program to get the difference between two dates in days

0

 Write a C# Sharp program to get the difference between two dates in days. 

Expected Output :

Difference in days: 2253

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
class Example30
{
    public static void Main() 
    {
     //establish DateTimes
DateTime start = new DateTime(2010, 6, 14);
DateTime end = new DateTime(2016, 08, 14);

TimeSpan difference = end - start; //create TimeSpan object

Console.WriteLine("Difference in days: " + difference.Days); //Extract days, write to Console.
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now