请问怎么知道当前月份的最后一天究竟是31日还是30、还是29?

解决方案 »

  1.   

    先判断是不是闰年pdrn(year),然后用switchif(pdrn(year)==1&&month==2)
    {
      return 29;
    }
    else
    {
      switch(month)
      {
        case 1: return 31;break;
        case 2: return 28;break;
        ……
      }
    }
      

  2.   

    int myDay=new DateTime(DateTime.Now.Year,DateTime.Now.Month+1,1).AddDays(-1).Day;
      

  3.   

    DateTime.Now.AddMonths(1).AddDays(-1);
      

  4.   

    int day=System.DateTime.DaysInMonth(System.DateTime.Today.Year,System.DateTime.Today.Month); //获得当前月份多少天