AddDays() not working within a while loop

Posted by r0bb077 on Stack Overflow See other posts from Stack Overflow or by r0bb077
Published on 2012-03-30T11:25:05Z Indexed on 2012/03/30 11:28 UTC
Read the original article Hit count: 138

Filed under:

Is there anything that stops the DateTime AddDays() method that doesn't run within a while loop. I have this simple bit of code;

DateTime last_day = monthCalendar2.SelectionRange.End;
DateTime first_day = new DateTime(year, month, day);

//Insert dates into vector
while (first_day != last_day)
{
  dates.Add(first_day);
  first_day.AddDays(1);
}

I step through the program and first_day never changes, anyone know why?!

© Stack Overflow or respective owner

Related posts about c#