Guest User

NonWorkingDays

a guest
Oct 2nd, 2016
1,683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3.  
  4. class HolidaysBetweenTwoDates
  5. {
  6.     static void Main()
  7.     {
  8.         var startDate = DateTime.ParseExact(Console.ReadLine(),
  9.             "d.M.yyyy", CultureInfo.InvariantCulture);
  10.         var endDate = DateTime.ParseExact(Console.ReadLine(),
  11.             "d.M.yyyy", CultureInfo.InvariantCulture);
  12.         var holidaysCount = 0;
  13.         for (var date = startDate; date <= endDate; date = date.AddDays(1))
  14.             if (date.DayOfWeek == DayOfWeek.Saturday ||
  15.                 date.DayOfWeek == DayOfWeek.Sunday) holidaysCount++;
  16.         Console.WriteLine(holidaysCount);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment