Returns a DateTime object that is offset the specified number of years from the specified DateTime object.
virtual DateTime AddYears(
The DateTime to which to add years.
The positive or negative number of years to add.
The resulting DateTime is outside the supported range.
years is less than -10,000 or greater than 10,000.
The Kind property of the returned DateTime value always equals DateTimeKind::Unspecified. You can preserve the Kind property of the time parameter by calling the DateTime::SpecifyKind method, as the following example shows.
The following code example demonstrates the use of the AddYears method.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.