Mega Code Archive

 
Categories / C# / Date Time
 

Returns the number of days in the specified month and year

using System; class Sample  {     public static void Main()      {       int July = 7;       int Feb = 2;       int daysInJuly = System.DateTime.DaysInMonth(2001, July);       int daysInFeb = System.DateTime.DaysInMonth(1998, Feb);       int daysInFebLeap = System.DateTime.DaysInMonth(1996, Feb);     } }