StartOfWeek

 public static DateTime TakeStartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
        {
            int diff = dt.DayOfWeek - startOfWeek;
            if (diff < 0)
            {
                diff += 7;
            }
            return dt.AddDays(-1 * diff).Date;
        }
Example:
DateTime weekBeginning = Week.TakeStartOfWeek(DayOfWeek.Monday);

Description

TakeStartOfWeek

Details

Double click on the code to select all.

 

;