- using System;
- namespace forgetCode
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter year in the format dd-mm-yyyy");
- DateTime dt = Convert.ToDateTime(Console.ReadLine());
- Console.WriteLine("Enter the months to add :");
- int months = Convert.ToInt32(Console.ReadLine());
- DateTime newDate = dt.AddMonths(months);
- Console.WriteLine(newDate.ToShortDateString());
- }
- }
- }
- Output:
- Enter year in the format dd-mm-yyyy
- 02-03-2012
- Enter the months to add :
- 4
- 02-07-2012
- Enter year in the format dd-mm-yyyy
- 20-11-2012
- Enter the months to add :
- 2
- 20-01-2013
- ..