#region 根據月份來確定每月的最大天數 private int SetDate(string time) { int intYear; int intMonth; int intDay; string year = time.Substring(0,4); string month = time.Substring(4,2); int.TryParse(year, out intYear); int.TryParse(month, out intMonth); if (intMonth == 02) { if (intYear % 400 == 0 || (intYear % 4 == 0 && intYear % 100 != 0))//判斷是不是閏年 { intDay = 29; } else { intDay = 28; } } switch (intMonth) { case 04: case 06: case 09: case 11: intDay = 30; break; default: intDay = 31; break; } return intDay; } #endregion
本文URL:http://www.bianceng.cn/Programming/csharp/201410/45588.htm