C#判断日期是否合法
static bool ValidateDate(int y, int m, int d) { int[] a = { 31, (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; return m >= 1 && m <= 12 && d >= 1 && d <= a[m - 1]; }
转自:http://outofmemory.cn/code-snippet/4892/C-decide-nian-yueri-shifou-hefa