NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

GregorianCalendar.AddYears

Returns the DateTime resulting from adding the given number of years to the specified DateTime.

[Visual Basic]
Overrides Public Function AddYears( _
   ByVal time As DateTime, _
   ByVal years As Integer _
) As DateTime
[C#]
public override DateTime AddYears(
   DateTime time,
   int years
);
[C++]
public: override DateTime AddYears(
   DateTime time,
   int years
);
[JScript]
public override function AddYears(
   time : DateTime,
   years : int
) : DateTime;

Parameters

time
The DateTime instance to be added.
years
A number of years (positive or negative).

Exceptions

Exception Type Condition
ArgumentException if the resulting DateTime is outside the supported range.

Remarks

The result is computed by incrementing (or decrementing) the year part of the specified DateTime by years. If the month and day of the specified DateTime is 2/29, and if the resulting year is not a leap year, the month and day of the resulting DateTime becomes 2/28. Otherwise, the month, day, and time-of-day parts of the result are the same as those of the specified DateTime.

See Also

GregorianCalendar Class | GregorianCalendar Members | System.Globalization Namespace