.

Leap Year algorithm in C#

by Simon Deshaies 24. December 2009 04:35

It’s not because it’s complex that I’m posting this and it’s neither because it’s hard to come by. It exist as pseudo code in Wikipedia.

It’s rather because it’s fun. You get to answer a bunch of fun questions. Like is 2010 a leap year? Was I born a leap year?

OK, it’s not like you could not calculate that in your head. But the fun part is how it looks like in C#. You know, C# being the BEST language in the WORLD! ;)

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

Tags:

Powered by BlogEngine.NET
Theme by Mads Kristensen and Simon Deshaies

About the author

Simon Deshaies

Name of authorI do web development, I focus on your business processes by dramatically increasing your visibility. I develop strong Internet and Web applications. My main objective is to support your performance by optimizing your presence on the Web and to advise you on the best web technology to fit your needs.

Linked in profile

Specialties:
.NET development, Internet and Web applications.
HTML, XHTML, XML, XSL, CSS, ASP.NET, AJAX, C#, SQL.
Microsoft Windows Server 2000 to 2008, SQL Server 2000 to 2008, MySQL, IIS, DNS.

BlogRoll

Download OPML file OPML