A DateTime extension method that query if '@this' is a week day. - CSharp System

CSharp examples for System:DateTime Week

Description

A DateTime extension method that query if '@this' is a week day.

Demo Code

// Copyright (c) 2015 ZZZ Projects. All rights reserved
using System;//from   ww w  . j a  v  a 2s  . c o  m

public class Main{
        /// <summary>
    ///     A DateTime extension method that query if '@this' is a week day.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>true if '@this' is a week day, false if not.</returns>
    public static bool IsWeekDay(this DateTime @this)
    {
        return !(@this.DayOfWeek == DayOfWeek.Saturday || @this.DayOfWeek == DayOfWeek.Sunday);
    }
}

Related Tutorials