using System.Collections.Generic;
public static void Main()
var startDate = new DateTime(2020, 2, 15);
var endDate = new DateTime(2020, 12, 31);
var yearMonths = GetYearMonths(startDate, endDate);
foreach (var yearMonth in yearMonths)
Console.WriteLine(yearMonth);
private static IEnumerable<(int Year, int Month)> GetYearMonths(DateTime startDate, DateTime endDate)
while (startDate <= endDate)
yield return (startDate.Year, startDate.Month);
startDate = startDate.AddMonths(1);