title: C# Month and Day Occurrence in between the dates
body: <p>I've a Month and day list and i need to search each month and day in this list in between the given dates. Can any one suggest me to do best way to get desired output.</p>
  
  <p>Eg:   </p>
  
  <blockquote>
    <p>Month day list -> 01/11, 03/15, 05/25, 09/01</p>
    
    <p>Between dates -> 01/01/2012 to 07/01/13</p>
  </blockquote>
  
  <p>Expected result: </p>
  
  <blockquote>
    <p>01/11/2012, 01/11/2013</p>
    
    <p>03/15/2012, 03/15/2013</p>
    
    <p>05/25/2012, 05/25/2013</p>
    
    <p>09/01/2012</p>
  </blockquote>
  
  <p>I tried like this but it gives memory exception and time and memory complexity increases if from date and to date having number of years gap, is there any quick solution to get it?</p>
  
  <pre><code>DateTime[] dateDates = new DateTime[dateTypeList.Rows.Count];
  //convert strings to datetimes:
  for (int i = 0; i &lt; dateTypeList.Rows.Count; i++)
  {
      dateDates[i] = Convert.ToDateTime(Convert.ToDateTime(string.Format("{0}/{1}", Convert.ToInt32(dateTypeList.Rows[i]["Month"]), Convert.ToInt32(dateTypeList.Rows[i]["Day"]))));
  }
  
  //define start and end time:
  DateTime dateStart = new DateTime(2012, 1, 1);
  DateTime dateEnd = new DateTime(2013, 7, 1);
  
  List&lt;DateTime&gt; results = new List&lt;DateTime&gt;();
  //loop days between start and end time:
  for (DateTime a = dateStart; a &lt;= dateEnd; a.AddDays(1))
  {
      for (int i = 0; i &lt; dateDates.Length; i++)
      {
          if (dateDates[i] == a)
          {
              results.Add(a);
          }
      }
  }
  </code></pre>