How to print the months in a year in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        DateTime now = DateTime.Now;
        
        for (int i = 0; i < 12; i++) {
            Console.WriteLine(now.ToString("MMM") + " - " + now.ToString("MMMM"));
            now = now.AddMonths(1);
        }
    }
}




/*
run:

Sep - September
Oct - October
Nov - November
Dec - December
Jan - January
Feb - February
Mar - March
Apr - April
May - May
Jun - June
Jul - July
Aug - August

*/

 



answered Sep 12, 2020 by avibootz
...