不是高手幫頂,
逐行判斷該列是否都為數字或字符!

解决方案 »

  1.   

    把他的数据放到一个对像中,如  public class Class1: IComparable<Class1>
        {
        
            public string _id = String.Empty;
           
           /// <summary>
            ///自定义比较器
            /// </summary>
            /// <param name="other"></param>
            /// <returns></returns>
            public int CompareTo(Class1 other)
            {
                if (other == null)
                    return 1;
                if (this == null)
                    return -1;
                int _idthis=0;
                int _idother=0;
                if(int.TryParase(this.Id,out _idthis) && int.TryParse(other.Id,out _idother))
                {
                    return _idthis.CompareTo(_idother);
                }
                else if(int.TryParase(this.Id,out _idthis))
                {
                   return 1;
                )
               else if(int.TryParase(other.Id,out _idother))
                {
                   return _1;
                )          return this.Id.CompareTo(other.Id);           
    }如:List<Class1> list=new List<Class1>();
    list.Add(new Class1("111"));
    list.Add(new Class1("2222"));
    list.Add(new Class1("112D1"));
    list.Add(new Class1("222C2"));list.sort(); //进行排序
      

  2.   

    不用判断,不管有没有字符串,都按字符串排序。就算全是数字,按字符串排序的结果和按整形排的结果是一样的。