EnumerableUtility.TryFirst<T> method (1 of 2)

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.

Return Value

True if the sequence is not empty; otherwise, false.

See Also


EnumerableUtility.TryFirst<T> method (2 of 2)

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.

Return Value

True if any elements in the source sequence pass the test in the specified predicate; otherwise, false.

See Also