Get Monday Of This Week - CSharp System

CSharp examples for System:DateTime Day

Description

Get Monday Of This Week

Demo Code


using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;/*from   www .j  av a 2s .  c  om*/

public class Main{
        public static DateTime GetMondayOfThisWeek(DateTime today)
        {
            int dayOfWeek = Convert.ToInt32(today.DayOfWeek.ToString("d"));
            if (dayOfWeek == 0) dayOfWeek = 7;
            return today.AddDays(1-dayOfWeek);
        }
}

Related Tutorials