Getting the list of days of the current week from DateTime.Now

My paradoxical or perhaps trivial problem is to create me a list of the days in format DD - MM - YY from the date of today . Suppose we have today is the " 11/04/2015 " ok ? I would be interested to create a list of datetime that starts exactly from Monday, 02.11.2015 to Sunday, 08.11.2015 . How is this possible? I thought initially :

DateTime today = new DateTime.Now;

int posDayOfWeek = (int)today.DayOfWeek;

if (posDayOfWeek < 7 && posDayOfWeek > 1)
{
    // And from there a black hole in my brain ....
}

I do not really know how to do ....

Thank you cordially Cristian Capannini

Jon Skeet
people
quotationmark

Assuming you always want Monday to Sunday, you just need something like:

DateTime today = DateTime.Today;
int currentDayOfWeek = (int) today.DayOfWeek;
DateTime sunday = today.AddDays(-currentDayOfWeek);
DateTime monday = sunday.AddDays(1);
// If we started on Sunday, we should actually have gone *back*
// 6 days instead of forward 1...
if (currentDayOfWeek == 0)
{
    monday = monday.AddDays(-7);
}
var dates = Enumerable.Range(0, 7).Select(days => monday.AddDays(days)).ToList();

people

See more on this question at Stackoverflow