SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method ElementAtAsync

    ElementAtAsync<TSource>(IAsyncEnumerable<TSource>, Index, CancellationToken)

    Returns the element at a specified index in a sequence.

    Declaration
    public static ValueTask<TSource> ElementAtAsync<TSource>(this IAsyncEnumerable<TSource> source, Index index, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    IAsyncEnumerable<TSource> source

    An IAsyncEnumerable<T> to return an element from.

    Index index

    The index of the element to retrieve, which is either from the start or the end.

    CancellationToken cancellationToken

    The optional cancellation token to be used for cancelling the sequence at any time.

    Returns
    Type Description
    ValueTask<TSource>

    The element at the specified position in the source sequence.

    Type Parameters
    Name Description
    TSource

    The type of the elements of source.

    Remarks

    This method throws an exception if index is out of range. To instead return a default value when the specified index is out of range, use the ElementAtOrDefaultAsync<TSource>(IAsyncEnumerable<TSource>, Index, CancellationToken) method.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentOutOfRangeException

    index is outside the bounds of the source sequence.

    © SuperLinq Authors. All rights reserved.