Date.IsLeapYear C# (CSharp) Method

IsLeapYear() public static method

public static IsLeapYear ( int year ) : bool
year int
return bool
    public static bool IsLeapYear(int year)
    {
        return (year % 4 == 0) && (year % 100 != 0 || year % 400 == 0);
    }

Usage Example

Ejemplo n.º 1
0
 public void DateExceptions()
 {
     Assert.ThrowsException <ArgumentOutOfRangeException>(() => { Date d = new Date(0, 1, 1); });
     Assert.ThrowsException <ArgumentOutOfRangeException>(() => { Date d = new Date(2000, -1, 1); });
     Assert.ThrowsException <ArgumentOutOfRangeException>(() => { Date d = new Date(2000, 1, 32); });
     Assert.ThrowsException <ArgumentOutOfRangeException>(() => Date.IsLeapYear(-1));
     Assert.ThrowsException <ArgumentNullException>(() => new Date(2000, 1, 15).ToString((string)null !));
 }
All Usage Examples Of Date::IsLeapYear