Advertisement
Guest User

[C#] Strings and Text Processing - 16

a guest
Jan 31st, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. using System;
  2.  
  3. class CalculateDaysBetweenDates
  4. {
  5. static void Main()
  6. {
  7. // write a program that reads two dates in the format: day.month.year
  8. // and calculates the number of days between them.
  9.  
  10. string start = Console.ReadLine();
  11. string end = Console.ReadLine();
  12. string[] startValues = start.Split('.');
  13. string[] endValues = end.Split('.');
  14.  
  15. DateTime endDate =
  16. new DateTime(int.Parse(endValues[2]),int.Parse(endValues[1]), int.Parse(endValues[0]));
  17. DateTime startDate =
  18. new DateTime(int.Parse(startValues[2]), int.Parse(startValues[1]), int.Parse(startValues[0]));
  19. TimeSpan countdays = endDate - startDate;
  20. Console.WriteLine(countdays.Days);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement