SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method ElementAtOrDefaultAsync

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

    Returns the element at a specified index in a sequence or a default value if the index is out of range.

    Declaration
    public static ValueTask<TSource?> ElementAtOrDefaultAsync<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>

    default if index is outside the bounds of the source sequence; otherwise, the element at the specified position in the source sequence.

    Type Parameters
    Name Description
    TSource

    The type of the elements of source.

    Remarks

    The default value for reference and nullable types is null.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    © SuperLinq Authors. All rights reserved.