using System.Collections.Generic;
public static readonly Dictionary<int, int> DaysInTheMonth = new()
public static void Main()
var days = GetTotalDays(startMonth, endMonth);
Console.WriteLine($"\nCounting the days in the months {startMonth} through {endMonth} results in a total of {days} days");
private static int GetTotalDays(int startMonth, int endMonth)
var months = DaysInTheMonth.Select(entry => entry.Key);
if (endMonth >= startMonth)
.Where(m => m >= startMonth && m <= endMonth);
.Where(m => m >= startMonth || m <= endMonth);
foreach (var month in months)
Console.WriteLine($"Adding {DaysInTheMonth[month]} days (month {month})");
days += DaysInTheMonth[month];