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;
The DateTime resulting from adding the specified number of years to the specified DateTime.
Exception Type | Condition |
---|---|
ArgumentException | is thrown if the resulting DateTime is outside the supported range. |
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.
Calendar Class | Calendar Members | System.Globalization Namespace