Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- namespace CountWorkingDays
- {
- class Program
- {
- static void Main(string[] args)
- {
- DateTime startDate = Convert.ToDateTime(Console.ReadLine());
- DateTime endDate = Convert.ToDateTime(Console.ReadLine());
- //DateTime startDate = DateTime.ParseExact(Console.ReadLine(), "dd-MM-yyyy", CultureInfo.InvariantCulture);
- //DateTime endDate = DateTime.ParseExact(Console.ReadLine(), "dd-MM-yyyy", CultureInfo.InvariantCulture);
- int count = 0;
- List<DateTime> dt = "01-01 03-03 01-05 06-05 24-05 06-09 22-09 01-11 24-12 25-12 26-12"
- .Split(' ').
- Select(x => Convert.ToDateTime(x))
- .ToList();
- for (var day = startDate.Date; day <= endDate.Date; day = day.AddDays(1))
- {
- if (day.DayOfWeek == DayOfWeek.Saturday || day.DayOfWeek == DayOfWeek.Sunday)
- {
- //count++;
- } else if (dt.Any(x => x.Day == day.Day && x.Month == day.Month ))
- {
- //count++;
- }
- else
- {
- count++;
- }
- }
- Console.WriteLine(count);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement