// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; class Calendar { public static int DaysInMonth(int y, int m) { DateTime dt = new DateTime(y, m+1, 1); dt = dt.AddDays(-1); return dt.Day; } public static void Main(string[] args) { Console.WriteLine(DaysInMonth(2004,5)); Console.WriteLine(DateTime.DaysInMonth(2004,5)); } }