title: How to get dates between two dates in C#
body: <p>I would like to get dates between two dates. Instead of expected <strong>9</strong> different dates, I get <strong>875287</strong> and <em>run out of memory</em>. What would be the problem with the code below?</p>
  <p><code>StartDate</code> value is <code>01/04/2016 00:00:00</code></p>
  <p><code>EndDate</code> value is <code>10/04/2016 00:00:00</code></p>
  <pre><code>var selectedDates = new List&lt;DateTime?&gt;();
  
  for (var date = StartDate; date &lt;= EndDate; date.Value.AddDays(1))
  {
      selectedDates.Add(date);
  }
  </code></pre>