DateTime::IsLeapYear Method (Int32)

 

Returns an indication whether the specified year is a leap year.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public:
static bool IsLeapYear(
	int year
)

Parameters

year
Type: System::Int32

A 4-digit year.

Return Value

Type: System::Boolean

true if year is a leap year; otherwise, false.

Exception Condition
ArgumentOutOfRangeException

year is less than 1 or greater than 9999.

year is specified as a 4-digit base 10 number; for example, 1996.

year is always interpreted as a year in the Gregorian calendar. To determine whether a particular year was a leap year in some other calendar, call that calendar object's IsLeapYear method.

The following example uses the IsLeapYear method to determine which years between 1994 and 2014 are leap years. The example also illustrates the result when the AddYears method is used to add a year to a leap day.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: