LINQ:
Enumerable.Range(0, 1 + end.Subtract(start).Days)
.Select(offset => start.AddDays(offset))
.ToArray();
For loop:
var dates = new List<DateTime>();
for (var dt = start; dt <= end; dt = dt.AddDays(1))
{
dates.Add(dt);
}
EDIT:
As for padding values with defaults in a time-series, you could enumerate all the dates in the full date-range, and pick the value for a date directly from the series if it exists, or the default otherwise. For example:
var paddedSeries = fullDates.ToDictionary(date => date, date => timeSeries.ContainsDate(date)
? timeSeries[date] : defaultValue);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…