Im trying to get the next five weekdays and im stuck.
Ive started like this:
List<DateTime> allWeekEndsInOneYear = new List<DateTime>();
DateTime sDate = DateTime.Now;
DateTime eDate = DateTime.Now.AddYears(1);
TimeSpan diff = eDate - sDate;
int days = diff.Days;
for (var i = 0; i <= days; i++)
{
var testDate = sDate.AddDays(i);
switch (testDate.DayOfWeek)
{
case DayOfWeek.Saturday:
case DayOfWeek.Sunday:
allWeekEndsInOneYear.Add(testDate);
break;
}
}
List<DateTime> daysToMark = new List<DateTime>();
DateTime startDate = DateTime.Now;
DateTime endDate = DateTime.Now.AddDays(5);
Now I need to fill daysToMark with the next 5 days excluding the weekeds (the ones in allWeekEndsInOneYear). Any help is very appreciated.
This will give you the next five days that are not a Saturday or Sunday.