Returns true if the sequence is not empty and provides the first element.
public static bool TryFirst<T>(this IEnumerable<T> source, out T? found)
| parameter | description |
|---|---|
| T | The type of the elements of source. |
| source | The source sequence. |
| found | The first item, if any. |
True if the sequence is not empty; otherwise, false.
Determines whether any element of a sequence satisfies a condition.
public static bool TryFirst<T>(this IEnumerable<T> source, Func<T, bool> predicate, out T? found)
| parameter | description |
|---|---|
| T | The type of the elements of source. |
| source | The source sequence. |
| predicate | The predicate. |
| found | The first item that satisfies the predicate, if any. |
True if any elements in the source sequence pass the test in the specified predicate; otherwise, false.