In this other question it shows how to get all days of a month. I need the same thing, but I only want to list days of week (I want to exclude weekends).
How can I get a list of days of a month excluding weekends?
In this other question it shows how to get all days of a month. I need the same thing, but I only want to list days of week (I want to exclude weekends).
How can I get a list of days of a month excluding weekends?
Well, how about:
public static List<DateTime> GetDates(int year, int month)
{
return Enumerable.Range(1, DateTime.DaysInMonth(year, month))
.Select(day => new DateTime(year, month, day))
.Where(dt => dt.DayOfWeek != DayOfWeek.Sunday &&
dt.DayOfWeek != DayOfWeek.Saturday)
.ToList();
}