c#: initialize a DateTime array
DateTime [] startDate = new DateTime[5];
startDate[0] = new DateTime(11, 11, 10);
startDate[1] = new DateTime(11, 11, 10);
startDate[2] = new DateTime(11, 11, 10);
startDate[3] = new DateTime(11, 11, 10);
startDate[4] = new DateTime(11, 11, 10);
You mean like this?
DateTime[] dateTimes = new DateTime[]
{
new DateTime(2010, 10, 1),
new DateTime(2010, 10, 2),
// etc
};
If you want to build an array for time span between two dates you could do something like this:
timeEndDate = timeStartDate.AddYears(1); // or .AddMonts etc..
rangeTimeSpan = timeEndDate.Subtract(timeStartDate); //declared prior as TimeSpan object
rangeTimeArray = new DateTime[rangeTimeSpan.Days]; //declared prior as DateTime[]
for (int i = 0; i < rangeTimeSpan.Days; i++)
{
timeStartDate = timeStartDate.AddDays(1);
rangeTimeArray[i] = timeStartDate;
}