How to print the months in a year in three letter format with 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 = now.AddMonths(1);
        }
    }
}




/*
run:

Sep
Oct
Nov
Dec
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug

*/

 



answered Sep 12, 2020 by avibootz
...