SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method Move

    | Edit this page

    Move<T>(IEnumerable<T>, int, int, int)

    Returns a sequence with a range of elements in the source sequence moved to a new offset.

    Declaration
    public static IEnumerable<T> Move<T>(this IEnumerable<T> source, int fromIndex, int count, int toIndex)
    Parameters
    Type Name Description
    IEnumerable<T> source

    The source sequence.

    int fromIndex

    The zero-based index identifying the first element in the range of elements to move.

    int count

    The count of items to move.

    int toIndex

    The index where the specified range will be moved.

    Returns
    Type Description
    IEnumerable<T>

    A sequence with the specified range moved to the new position.

    Type Parameters
    Name Description
    T

    Type of the source sequence.

    Remarks

    This operator uses deferred execution and streams its results.

    Examples

    The following code example demonstrates how to move a subsequence from one location to another using Move.

    var sequence = Enumerable.Range(0, 6);
    
    // move a subsequence within the larger sequence
    var result = sequence
        .Move(3, 2, 0);
    
    Console.WriteLine(
        "[" +
        string.Join(", ", result) +
        "]");
    
    // This code produces the following output:
    // [3, 4, 0, 1, 2, 5]
    
    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentOutOfRangeException

    fromIndex, count, or toIndex is less than 0.

    © SuperLinq Authors. All rights reserved.