求教高手:怎么用文本框显示月份的天数 说的最好具体些

解决方案 »

  1.   

    textbox.text = datetime.now.day.tostring();
      

  2.   


     DateTime.DaysInMonth(year,month)
      

  3.   

    using System;
    public class TestMonth
    {
    public static int DayNumOfMonth(DateTime v_date)//获取月份天数
    {
    int v_month,v_year;
    v_month = v_date.Month;
    v_year = v_date.Year;
    switch(v_month){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12: return 31;
    case 4:
    case 6:
    case 9:
    case 11: return 30;
    case 2:
    if (DateTime.IsLeapYear(v_year)) //判断润年
    {
    return 29;
    }
    else return 28;
    default: return 0;
    }
    }
    public static void Main()
    {
    Console.WriteLine(TestMonth.DayNumOfMonth(DateTime.Now));
    Console.ReadLine();
    }
    };
      

  4.   

    我错了。。我不知道有这个函数。。用这个函数吧
    DateTime.DaysInMonth(year,month)
      

  5.   

    DateTime.DaysInMonth(year,month)
    就是这个了!!!