You can skip the while loop and use
DateTime mondayOfLastWeek = date.AddDays( -(int)date.DayOfWeek - 6 );
This assumes you’re using Monday as the first day of the week.
You can skip the while loop and use
DateTime mondayOfLastWeek = date.AddDays( -(int)date.DayOfWeek - 6 );
This assumes you’re using Monday as the first day of the week.