title: How can I get a collection of months between two Dates?
body: <p>Below is my code. I am only getting the difference between two dates, but I want the name of that month which comes between the from and to dates. </p>
  
  <pre><code>public static int GetMonthsBetween(DateTime from, DateTime to)
  {
      if (from &gt; to) return GetMonthsBetween(to, from);
  
      var monthDiff = Math.Abs((to.Year * 12 + (to.Month - 1)) - (from.Year * 12 + (from.Month - 1)));
  
      if (from.AddMonths(monthDiff) &gt; to || to.Day &lt; from.Day)
      {
          return monthDiff - 1;
      }
      else
      {
          return monthDiff;
      }
  }
  </code></pre>