Donate

How To Check if Leap Year In C#.NET

Hello,

Below is a custom code i have been working to check if a year is considered as leap year.
  protected bool CheckLeap(int year)  
  {  
     if((year%4==0&&year%100!=0)||year%400==0)  
     {  
       return true;  
     }  
     return false;  
  }  
However, as i checked the DateTime class methods in MSDN, i found a handy tool to do the same functionality.
DateTime.IsLeapYear(int year); 

Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

Bootstrap Modal In ASP.NET MVC With CRUD Operations