Mega Code Archive

 
Categories / C# Tutorial / Date Time
 

Use the DaysInMonth() method to retrieve the number of days in a particular month and year

using System; class MainClass {   public static void Main()   {     int days = DateTime.DaysInMonth(2004, 1);     Console.WriteLine("DateTime.DaysInMonth(2004, 1) = " + days);   } } DateTime.DaysInMonth(2004, 1) = 31