我的代码是这样
int _month , _year ;
_month = int.Parse ( ddltMonth.SelectedItem.Text ) ;
_year = int.Parse ( ddltYear.SelectedItem.Text ) ;
DateTime month= new DateTime ( _year , _month ) ;
出现的错误是:
最后一句不可访问,它受到保护级别的限制,朋友们帮忙!!!

解决方案 »

  1.   

    DateTime Date = DateTime.ParseExact(ddltYear.SelectedItem.Text+"-"+ddltMonth.SelectedItem.Text,"yyyy-M",new CultureInfo("zh-CN", false));
      

  2.   

    System.Globalization.DateTimeFormatInfo dTFI = new System.Globalization.DateTimeFormatInfo();
    dTFI.DateSeparator = "-";
    string tagTime = "2004-01-01";
    DateTime myDateTime = DateTime.Parse(tagTime,dTFI);
      

  3.   

    DateTime month= new DateTime ( _year , _month ) ;
    这一句写的真有意思
      

  4.   

    为什么不用DateTimePicker控件?
    出错是因为你没有写入日,C#默认时间格式根据你的系统默认时间格式。应该是yyyy-mm-dd.
      

  5.   

    xrll()
    CultureInfo要用到哪个引用集?
      

  6.   

    xrll() 的可以,不过需要using System.Globalization;