Advertisement
soxa

DateDaysB

Jan 18th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. /*Write a program that reads two dates in the format: day.month.year and calculates the number of days between them. */
  2. namespace EX16.BetweenTwoDate
  3. {
  4.     using System;
  5.     using System.Collections.Generic;
  6.     using System.Linq;
  7.     using System.Text;
  8.     using System.Threading.Tasks;
  9.  
  10.     class BetweenTwoDate
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int count = 0;
  15.             DateTime firstDate = DateTime.Parse("27.02.2006");
  16.             DateTime secondDate = DateTime.Parse("3.03.2004");
  17.  
  18.             while (firstDate.Day != secondDate.Day)
  19.             {
  20.                firstDate = firstDate.AddDays(1);
  21.                 count++;
  22.             }
  23.  
  24.             Console.WriteLine("Distance : {0}",count);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement