3
21/10/2024 6:29 pm
Aiheen aloittaja
Write a program that enters two dates in format dd.MM.yyyy and returns the number of days between them.
Examples:

1 Vastaus
2
21/10/2024 6:30 pm
First read more about TimeSpan Structure HERe: https://msdn.microsoft.com/en-us/library/system.timespan%28v=vs.110%29.aspx
and here is the code:
using System;
class DifferenceBetweenDates
{
static void Main()
{
DateTime firstDate = DateTime.Parse(Console.ReadLine());
DateTime secondDate = DateTime.Parse(Console.ReadLine());
TimeSpan dif = secondDate - firstDate;//Class wich represents a time interval.
int days = dif.Days;//.Days is a property of the class TimeSpan which shows the days
Console.WriteLine("{0}", days);
}
}
