IndexOf<>(source, predicate, startIndex) IndexOf<>(source, element, comparer) JoinString<>(values, separator, prefix, suffix, lastSeparator) Order<>(source, comparer) SkipLast<>(source, count, throwIfNotEnough) Split<>(splitWhat, splitWhere) Split<>(source, chunkSize) ToDictionary2<>(source, key1Selector, key2Selector, comparer1, comparer2) ToDictionary2<>(source, key1Selector, key2Selector, elementSelector, comparer1, comparer2)
Legend Class Struct Enum Interface Delegate | Constructor Method Property Event Field |
| Extension method: TResult FirstOrDefault<TSource, TResult>(this IEnumerable<TSource>, Func<TSource, bool>, Func<TSource, TResult>, TResult)Declarationpublic static TResult FirstOrDefault<TSource, TResult>(
this IEnumerable<TSource> source,
Func<TSource, bool> predicate,
Func<TSource, TResult> resultSelector,
TResult default
) Summary
Returns the first element of a sequence, or a default value if the sequence contains no elements. Generic type parametersTSource |
The type of the elements of source. | TResult |
The type of the resulting value. |
Parametersthis IEnumerable<TSource> | source |
The IEnumerable<T> to return the first element of. | Func<TSource, bool> | predicate |
A function to test each element for a condition. | Func<TSource, TResult> | resultSelector |
A function to transform the first element into the result value. Will only be called if the sequence contains
an element that passes the test specified by predicate. | TResult | default |
The default value to return if the sequence contains no elements. |
Returnsdefault if source is empty or if no element passes the test specified by
predicate; otherwise, the transformed first element in source that
passes the test specified by predicate. |