IEnumerable<T>.ElementAtOrDefault Method
Overloads
| ElementAtOrDefault(Integer) |
Returns the element at a specified index in the sequence or a default value if the index is out of range. |
| ElementAtOrDefault(Integer, T) |
Returns the element at a specified index in the sequence or the specified default value if the index is out of range. |
Returns the element at a specified index in the sequence or a default value if the index is out of range.
function ElementAtOrDefault(index: Integer): T
Parameters
- index
- Integer
The zero-based index of the element to retrieve.
Returns
Default(T) if the index is outside the bounds of the sequence;
otherwise, the element at the specified position in the sequence.
Returns the element at a specified index in the sequence or the specified default value if the index is out of range.
function ElementAtOrDefault(index: Integer; const defaultValue: T): T
Parameters
- index
- Integer
The zero-based index of the element to retrieve.
- defaultValue
- T
The value to return if the index is out of range.
Returns
defaultValue if the index is outside the bounds of the
sequence; otherwise, the element at the specified position in the
sequence.