请人帮忙解决一下这个排序的问题,用 不是高手幫頂,逐行判斷該列是否都為數字或字符! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把他的数据放到一个对像中,如 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(); //进行排序 不用判断,不管有没有字符串,都按字符串排序。就算全是数字,按字符串排序的结果和按整形排的结果是一样的。 winform时间控件的问题。 请问如何将System.byte[]的内容转成字符串输出? WPF,怎么把GroupBox外面的矩形框替换成另一种样式? 为什么全屏总是会不正常? 初学C#,请教如何运用命令行编译cs文件 关于ImageList添加图片的问题 三层开发数据层如何剥离?? 求教webservice的问题,请大家帮我看看这样对么? 怎么判断值类型的变量为空啊 请教一个正则表达式的写法 怎么把自己做好的程序打包啊? 如何将xml文件读取到dataGridView中啊
{
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(); //进行排序