Returns the DateTime result from adding this instance to the specified number of years.
[Visual Basic] Public Function AddYears( _ ByVal value As Integer _ ) As DateTime [C#] public DateTime AddYears( int value ); [C++] public: DateTime AddYears( int value ); [JScript] public function AddYears( value : int ) : DateTime;
DateTime results from adding the specified number of years to this instance.
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | If the resulting DateTime is outside the supported range. |
The AddYears method is computed by incrementing or decrementing the year part of this instance of DateTime by the number of specified years.
For example, if the month and day of this 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 this DateTime.
The value parameter argument can be either positive or negative.
DateTime Structure | DateTime Members | System Namespace | Int32 | Calendar | Year