SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method ElementAtOrDefault

    ElementAtOrDefault<TSource>(IEnumerable<TSource>, Index)

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

    Declaration
    [Obsolete("This method has been implemented by the framework.")]
    public static TSource? ElementAtOrDefault<TSource>(IEnumerable<TSource> source, Index index)
    Parameters
    Type Name Description
    IEnumerable<TSource> source

    An IEnumerable<T> to return an element from.

    Index index

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

    Returns
    Type Description
    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

    If the type of source implements IList<T>, that implementation is used to obtain the element at the specified index. Otherwise, this method obtains the specified element.

    This operator is implemented in the bcl as of net6. Source and binary compatibility should be retained across net versions, but this method should be inaccessible in net6+.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    © SuperLinq Authors. All rights reserved.