title: Getting all DateTimes between two 'DateTime's in C#
body: <p>I have two <code>DateTime</code>s, and I want to get all <code>DateTime</code>s between these Dates. Such as, if my Dates are like 01.01.2010 - 05.01.2010, my function should return me a list of date (List), and it must contain 01.01.2010, 02.01.2010, 03.01.2010, 04.01.2010, and 05.01.2010.</p>
  
  <p>I wrote a function like this. It works fine, if my dates are in a month. It won't work if my dates are like 01.01.2010 - 05.02.2010. Because the month changed, and my function can't handle it. Is there a function in C# that returns all dates between two dates? Or how can I handle month change?</p>
  
  <pre><code>public void GetAllDatesAndInitializeTickets(DateTime startingDate, DateTime endingDate)
      {
          List&lt;DateTime&gt; allDates = new List&lt;DateTime&gt;();
  
          int starting = startingDate.Day;
          int ending = endingDate.Day;
  
          for (int i = starting; i &lt;= ending; i++)
          {
              allDates.Add(new DateTime(startingDate.Year, startingDate.Month, i));
          }
  </code></pre>
  
  <p>Question solved, see Tim Robinson's simple answer to use.</p>