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

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.