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!

Calendar.AddYears

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

[Visual Basic]
MustOverride Public Function AddYears( _
   ByVal time As DateTime, _
   ByVal years As Integer _
) As DateTime
[C#]
public abstract DateTime AddYears(
   DateTime time,
   int years
);
[C++]
public: virtual DateTime AddYears(
   DateTime time,
   int years
) = 0;
[JScript]
public abstract function AddYears(
   time : DateTime,
   years : int
) : DateTime;

Parameters

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

Return Value

The DateTime resulting from adding the specified number of years to the specified DateTime.

Exceptions

Exception Type Condition
ArgumentException is thrown 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 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

Calendar Class | Calendar Members | System.Globalization Namespace