DateTime currentDate = new DateTime(2021, 10, 15); Calendar cal = new GregorianCalendar(); int monthsToAdd = 3; DateTime futureDate = cal.AddMonths(currentDate, monthsToAdd); Console.WriteLine("Current Date: " + currentDate); Console.WriteLine("Future Date: " + futureDate);
DateTime currentDate = new DateTime(2021, 10, 15); Calendar cal = CultureInfo.InvariantCulture.Calendar; int monthsToAdd = 7; DateTime futureDate = cal.AddMonths(currentDate, monthsToAdd); Console.WriteLine("Current Date: " + currentDate); Console.WriteLine("Future Date: " + futureDate);This example is similar to the first one, but it uses the CultureInfo.InvariantCulture.Calendar property to get the default calendar for the current culture. It also sets the number of months to add to 7, and displays the current and future dates. Package/Library: System.Globalization