A DateTime extension method that last day of week. - CSharp System

CSharp examples for System:DateTime Week

Description

A DateTime extension method that last day of week.

Demo Code

// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods)
using System;/*from  w ww . j  av a  2  s  .  c om*/

public class Main{
        /// <summary>
    ///     A DateTime extension method that last day of week.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>A DateTime.</returns>
    public static DateTime LastDayOfWeek(this DateTime @this)
    {
        return new DateTime(@this.Year, @this.Month, @this.Day).AddDays(6 - (int) @this.DayOfWeek);
    }
}

Related Tutorials