// 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; namespace E { public class Program { public static bool ValidDate(int y, int m, int d) { if(d > 28) { DateTime dt = new DateTime(y, m, d - 3); return dt.AddDays(3).Day == d; } else { return true; } } public static void Main(string[] args) { Console.WriteLine(ValidDate(2007, 7, 31)); Console.WriteLine(ValidDate(2007, 6, 31)); Console.WriteLine(ValidDate(2007, 7, 1)); Console.WriteLine(ValidDate(2007, 6, 1)); } } }