Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class CalculateDaysBetweenDates
- {
- static void Main()
- {
- // write a program that reads two dates in the format: day.month.year
- // and calculates the number of days between them.
- string start = Console.ReadLine();
- string end = Console.ReadLine();
- string[] startValues = start.Split('.');
- string[] endValues = end.Split('.');
- DateTime endDate =
- new DateTime(int.Parse(endValues[2]),int.Parse(endValues[1]), int.Parse(endValues[0]));
- DateTime startDate =
- new DateTime(int.Parse(startValues[2]), int.Parse(startValues[1]), int.Parse(startValues[0]));
- TimeSpan countdays = endDate - startDate;
- Console.WriteLine(countdays.Days);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement