Assembly: mscorlib (in mscorlib.dll)
- Type: System.Int32
The number of months to add.
The day part of the resulting DateTime is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting DateTime is affected if the resulting month is outside the year of the specified DateTime. The era part of the resulting DateTime is affected if the resulting year is outside the era of the specified DateTime. The time-of-day part of the resulting DateTime remains the same as the specified DateTime.
For example, suppose that the current calendar has 12 months, where the fourth month has 30 days and the tenth month has 31 days. If the specified month is the tenth month, the specified day is the 31st day of that month, and the value of the months parameter is 6, the resulting year is one more than the specified year, the resulting month is the fourth month, and the resulting day is the 30th day, which is the last day of the resulting month.
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.
.NET FrameworkSupported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
XNA FrameworkSupported in: 3.0, 2.0, 1.0
Portable Class LibrarySupported in: Portable Class Library
Supported in: Windows Phone 8.1
Supported in: Windows Phone Silverlight 8.1
Supported in: Windows Phone Silverlight 8