IsWeekend
Lets you easily figure out ifdateTime holds a date value that is a weekend.
Source
public static bool IsWeekend(this DateTime value)
{
return (value.DayOfWeek == DayOfWeek.Sunday || value.DayOfWeek == DayOfWeek.Saturday);
}
Example
for (DateTime date = dateFrom; date <= dateTo; date = date.AddDays(1))
{
if (date.IsWeekend()) continue;
// do some date related stuff
}