我用两个dropdownlist 来表示年和月  ,A和B 是两个对应的日期 只有年月
       
        string A = DropDownList1.ToString() + DropDownList2.ToString();        string B = DropDownList3.ToString() + DropDownList4.ToString();

解决方案 »

  1.   

      string A = DropDownList1.ToString() + DropDownList2.ToString();  string B = DropDownList3.ToString() + DropDownList4.ToString();
    你这个首先不是日期格式,还需要首先转换成日期格式,然后才能比较。与其这样,还不如直接比较年月大小。
      

  2.   

            DateTime t1 = DateTime.ParseExact("20120506", "yyyyMMdd", null);
            DateTime t2 = DateTime.ParseExact("20110506", "yyyyMMdd", null);
            int result = DateTime.Compare(t1, t2);
      

  3.   

    我用两个dropdownlist 一个表示年一个表示月,那该如何将其转化为日期类型呢
      

  4.   

    先将选中项的值转为int,然后在new DateTime