Mono Class Library: System.DateTime Overview | Members

System.DateTime.AddMonths Method

Adds a specified number of months to the value of the current instance. [Edit]

public DateTime AddMonths (int months)

Parameters

months
A int containing the number of months. months can be positive or negative, and may be greater than the number of months in a year. [Edit]

Returns

A DateTime instance set to the sum of the date and time represented by the current instance and months. [Edit]

Exceptions

TypeReason
ArgumentOutOfRangeException

The resulting DateTime is less than DateTime.MinValue or greater than DateTime.MaxValue.

-or-

The months parameter is less than -120,000 or greater than 120,000

[Edit]

Remarks

This method does not change the value of the current DateTime instance. Instead, a new DateTime instance is returned whose value is the result of this operation. [Edit]

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0