C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着
     int[] a = new int[] { 2, 1, 3, 6, 8, 7 };
            Array.Sort(a,new CompareAge());
            foreach (int temp in a)
            {
                Response.Write(temp.ToString()+"<br>");
            }
    public class CompareAge:IComparer
    {
        int IComparer.Compare(object a,object b)
        {
            int i = 0,j = 0;
            int.TryParse(a.ToString(),out i);
            int.TryParse(b.ToString(),out j);
            return i -j;
        }
    }
posted on 2009-06-15 18:23  王德田  阅读(140)  评论(0编辑  收藏  举报