using System; public class LeapYears { public static bool IsLeapYear(int year) { // End of a century must be divisible by 400 if(year%100==0) return year % 400 == 0;// Returns true if year divisible by 400, false otherwise else if(year % 4 == 0) return true;// Returns true if year divisible by 4 and not end of the century else return false; } }
- using System;
- public class LeapYears
- {
- public static bool IsLeapYear(int year)
- {
- // End of a century must be divisible by 400
if(year.ToString().EndsWith("00"))- if(year%100==0)
- return year % 400 == 0;// Returns true if year divisible by 400, false otherwise
- else if(year % 4 == 0)
- return true;// Returns true if year divisible by 4 and not end of the century
- else
- return false;
- }
- }