C# DateTime AddMonths
Description
DateTime AddMonths
returns a new DateTime that adds the
specified number of months to the value of this instance.
Syntax
DateTime.AddMonths
has the following syntax.
public DateTime AddMonths(
int months
)
Parameters
DateTime.AddMonths
has the following parameters.
months
- A number of months. The months parameter can be negative or positive.
Returns
DateTime.AddMonths
method returns An object whose value is the sum of the date and time represented by this instance
and months.
Example
The following code shows how to use DateTime.AddMonths
.
using System;/* www. j ava2 s . c o m*/
public class Example
{
public static void Main()
{
DateTime dateValue = new DateTime(2013, 9, 15, 12, 0, 0);
Console.WriteLine(dateValue.AddMonths(30));
}
}
The code above generates the following result.