public static List<T>  Swap<T>(this List<T> list, int index1,int index2)
        {
            if(index1<0||index1>=list.Count)
            {
                throw new Exception("index1");
            }
            if (index2 < 0 || index2 >= list.Count)
            {
                throw new Exception("index2");
            }
            var temp = list[index1];
            list[index1] = list[index2];
            list[index2] = temp;
            return list;
        }

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2021-09-27
  • 2022-02-05
  • 2021-12-20
  • 2021-10-20
猜你喜欢
  • 2021-05-08
  • 2022-12-23
  • 2021-09-23
  • 2021-07-03
  • 2021-12-24
  • 2021-11-18
  • 2021-12-05
相关资源
相似解决方案