[Python] Readable C# equivalent of Python slice operation

Discussão em 'Python' iniciado por Stack, Abril 11, 2025.

  1. Stack

    Stack Membro Participativo

    What is the C# equivalent of Python slice operations?

    my_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
    result1 = my_list[2:4]
    result2 = my_list[1:]
    result3 = my_list[:3]
    result4 = my_list[:3] + my_list[4:]


    Some of it is covered here, but it is ugly and doesn't address all the uses of slicing to the point of it not obviously answering the question.

    Continue reading...

Compartilhe esta Página