IsLeapYear

public static bool IsLeapYear(this DateTime value)
{
    return (System.DateTime.DaysInMonth(value.Year, 2) == 29);
}
Example:
if (DateTime.Today.IsLeapYear())
{
    Response.Write("It is a leap year!");
}

Description

Returns whether or not a DateTime is during a leap year.

Details

Double click on the code to select all.

 

;