Simple way to populate a List with a range of Datetime
.net, c#, datetime
Solution
var startDate = new DateTime(2013, 12, 1);
var endDate = new DateTime(2013, 12, 5);
var dates = Enumerable.Range(0, (int)(endDate - startDate).TotalDays + 1)
.Select(x => startDate.AddDays(x))
.ToList();
Problem
I trying to find a simple way to solve this. I have a Initial Date, and a Final Date. And I want to generate a `List<Datetime>` with each of the dates in a given period. Example : Initial Date is "2013/12/01" and Final Date is "2013/12/05". And I want to automatically populate a list with ``` "2013/12/01" "2013/12/02" "2013/12/03" "2013/12/04" "2013/12/05" ``` What would you suggest me? Thanks