CoderzHeaven

April 18, 2011

How to find a leap year using C# ?

Hi,

Sometimes you may need to find whether a particular year is leap year or not. But how can you find out whether a particular year is leap year or not in C# ? Use the following code.

using System;class MainClass{public static void Main(){bool myResult= DateTime.IsLeapYear(2011);Console.WriteLine("Is the year 2011 a leap year ? = " + myResult);}}

And the output is,
Is the year 2011 a leap year ? = False

🙂

Leave a Reply Cancel reply

2 Comments to “How to find a leap year using C# ?”