Check if the Year is Leap Year or Not in C#

How to check if the Year is Leap Year or Not? Using DateTime keyword we can easily find out whether the Year is Leap Year or Not in C#.

int varYear = 2010;
bool varResult = DateTime.IsLeapYear(varYear);
if (varResult.Equals(true))
{
        Response.Write(varYear + " is a Leap Year");           
}
else
{
        Response.Write(varYear + " is not a Leap Year");           
}

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
    or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

    ReplyDelete