I have 2 DateTimePicker
controls named dtp1
and dtp2
. I wish to get an array of dates between those 2 days: dtp1.Date.Value <= x <= dtp2.Date.Value.
I currently use for
loop to achieve such a task, but this is not a very efficient way to do things:
int c = (int)(dtp2.Value.Date-dtp1.Value.Date).TotalDays + 1;
DateTime[] d = new DateTime[c];
for (int i = 0; i < c; i++)
{
d[i] = dtp1.Value.Date.AddDays(i);
}
Is there any better and concise way to achieve the same result?