How to check whether the given year is a leap year in C# – Programming Code Examples
ASP.NET C#

How to check whether the given year is a leap year in C#2 min read

DateTime.IsLeapYear() method return a value which indicate whether a specified year is a leap year. this method exists in System namespace. DateTime.IsLeapYear(year) method need to pass a parameter named ‘year’. the ‘year’ parameter value data type is System.Int32 which represent a 4 digit year.

the method return value data type is System.Boolean. so its only return true or false. if the method return true then the specified year is a leap year. otherwise it is not a leap year. if the specified year is less than 1 and greater than 9999 then the method throw an exception named ArgumentOutOfRangeException.




the following asp.net c# example code demonstrate us how can we check whether a specified year is leap year or not programmatically at run time in an asp.net application.

How to check whether the given year is a leap year C#

How to check whether the given year is a leap year C#

ASP.NET

 

Leave a Comment