C# DateTime IsLeapYear
Description
DateTime IsLeapYear
returns an indication whether the
specified year is a leap year.
Syntax
DateTime.IsLeapYear
has the following syntax.
public static bool IsLeapYear(
int year
)
Parameters
DateTime.IsLeapYear
has the following parameters.
year
- A 4-digit year.
Returns
DateTime.IsLeapYear
method returns true if year is a leap year; otherwise, false.
Example
The following example uses the IsLeapYear method to determine which years between 1994 and 2014 are leap years.
using System;//from w w w .ja v a2 s. c o m
public class IsLeapYear
{
public static void Main()
{
for (int year = 1994; year <= 2014; year++)
{
if (DateTime.IsLeapYear(year))
{
Console.WriteLine("{0} is a leap year.", year);
}
}
}
}
The code above generates the following result.