SortedList类默认是升序的,要改成降序要怎么改呢?
通过实现IComparer:
    public class ReverserSort : IComparer<string>
    {
        private bool Asc=true;
        int IComparer<KeyValueItem>.Compare(string x, string y)
        {
            if (Asc)
              return string.Compare(x, y);
            else
              return string.Compare(y, x);

        }
        public bool bAsc
        {
            set { Asc = value; }
        }
       
    }
其中string类型也可以是其他类型
ReverserSort ms = new ReverserSort();
ms.Asc = false;
SortedList li = new SortedList();
Array.Sort(li, ms);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2023-03-31
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-10-28
相关资源
相似解决方案