判断闰年与平年的方法与获取指定月份的天数

1、判断闰年与平年的方法

   int  intmonth;
   if(System.DateTime.IsLeapYear(System.DateTime.Now.Date.Year)==true)  
   {  
    intmonth=29;        //闰年
   }  
   else  
   {  
    intmonth=28;        //平年
   } 

2、获取指定月份的天数

格式为:System.DateTime.DaysInMonth(int  指定的年份,int  指定的月份); 

一、当前月份的天数

int   idate=System.DateTime.DaysInMonth(System.DateTime.Now.Year,System.DateTime.Now.Month); 

posted @ 2010-12-15 09:36  闭着眼睛想  阅读(1051)  评论(0编辑  收藏  举报