int days() ... { int y,m,days=0; y=DateTime.Now.Year; m=DateTime.Now.Month; switch(m) ...{ case 1 : case 3 : case 5 : case 7 : case 8 : case 10 : case 12 : days = 31; break; case 4 : case 6 : case 9 : case 11 : days = 30; break; case 2: days = feb(y);//2月份单独处理/判断是否为闰年 break; } return days; } 2月份单独处理 int feb( int y) // 判断2月的天数 ... { //系统自带函数(返回指定的年份是否办闰年) //System.DateTime.IsLeapYear(y); //四年一闰,百年不闰;四百年再闰 if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) ...{ return 29; } else ...{ return 28; } }