End Of Week - CSharp System

CSharp examples for System:DateTime Week

Description

End Of Week

Demo Code


using System;/*  www.  j  a v a2  s .com*/

public class Main{
        public static DateTime EndOfWeek(this DateTime dt, DayOfWeek endOfWeek)
        {
            int diff = endOfWeek - dt.DayOfWeek;
            if (diff < 0)
                diff += 7;

            return dt.AddDays(diff).Date;
        }
}

Related Tutorials