C#获取月份天数

    技术2022-05-20  28

    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);

    最新回复(0)