I created a function for you that gives you an array of DateTime values of all days within the month!
public DateTime[] GetAllDays(int year, int month)
{
int days = DateTime.DaysInMonth(year, month);
DateTime[] dates = new DateTime[days];
for (int d = 0; d < days; d++)
{
dates[d] = new DateTime(year, month, (d + 1));
}
return dates;
}
To use this you should do:
DateTime[] dates = GetAllDays(2009, 3);
for(int d = 0; d < dates.Length; d++)
{
textBox1.Text += dates[d].ToLongDateString() + Environment.NewLine;
}
Result:
Sunday, March 01, 2009
Monday, March 02, 2009
Tuesday, March 03, 2009
...
...
...
Tuesday, March 31, 2009