日期:2014-05-18 浏览次数:20463 次
ArrayList al = new ArrayList();
al.Add("AAA");
al.Add("AAAA");
al.Add("A");
al.Add("AA");
myComp comp = new myComp();
al.Sort(comp);
for (int i = 0; i < al.Count; i++)
{
Response.Write(al[i] + "<BR>");
}
class myComp:IComparer
{
#region IComparer 成员
public int Compare(object x, object y)
{
return x.ToString().Length > y.ToString().Length ? 0 :1;
}
#endregion
}
------解决方案--------------------
8楼的高手已经给你实现了……
ArrayList.Sort
IComparer 接口~
------解决方案--------------------
8楼的思想不错。顶下
------解决方案--------------------
ding 8