Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Printing months in a year in three letter format in C#

The format MMM will give the months name in three letter format.


  1. using System;
  2.  
  3. namespace forgetCode
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. DateTime now = DateTime.Today;
  10. for (int i = 0; i < 12; i++)
  11. {
  12. Console.WriteLine(now.ToString("MMM"));
  13. now = now.AddMonths(1);
  14. }
  15. }
  16.  
  17. }
  18. }


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

..