ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods


Lets you easily figure out ifdateTime holds a date value that is a weekend.


public static bool IsWeekend(this DateTime value)
    return (value.DayOfWeek == DayOfWeek.Sunday || value.DayOfWeek == DayOfWeek.Saturday);


for (DateTime date = dateFrom; date <= dateTo; date = date.AddDays(1))
    if (date.IsWeekend()) continue;
    // do some date related stuff

Author: DavidV

Submitted on: 10 mrt 2008

Language: C#

Type: System.DateTime

Views: 11783