C# equivalent of rotating a list using python slice operation

后端 未结 6 1874
借酒劲吻你
借酒劲吻你 2020-12-14 06:52

In python, I can take a list my_list and rotate the contents:

>>> my_list = list(range(10))
>>> my_list
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>         


        
6条回答
  •  不知归路
    2020-12-14 07:27

    The closest thing in C# would be to use the Enumerable.Skip and Enumerable.Take extension methods. You could use these to build your new list.

提交回复
热议问题