Generate next 12 Months and Year from current date

Niladri.Biswas
Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 837
using System;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int totalmonths = 12;
for (int i = 0; i < totalmonths; i++)
{
var monthName = DateTime.Now.AddMonths(i).ToString("MMM");
var year = DateTime.Now.AddMonths(i).Year;
var concatenatedString = string.Format("{0} - {1}", monthName, year);
Console.WriteLine(concatenatedString);
}
Console.ReadKey();
}
}
}

Comments or Responses

Login to post response