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;
        }
    }

相关文章:

  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2021-05-31
  • 2021-05-17
  • 2022-12-23
猜你喜欢
  • 2021-09-30
  • 2021-06-26
  • 2022-01-19
  • 2022-02-24
  • 2022-12-23
  • 2022-01-11
相关资源
相似解决方案