IEnumerable<T>.TryGetFirst Method

Overloads

TryGetFirst(T)

Attempts to get the first element in the sequence.

TryGetFirst(T, Predicate<T>)

Attempts to get the first element in the sequence that satisfies a specified condition.

TryGetFirst(T)

Attempts to get the first element in the sequence.

Delphi
function TryGetFirst(var value: T): Boolean

Parameters

value
T

The first element in the sequence.

Returns

Boolean

True if the sequence was not empty; otherwise, False .

TryGetFirst(T, Predicate<T>)

Attempts to get the first element in the sequence that satisfies a specified condition.

Delphi
function TryGetFirst(var value: T; const predicate: Predicate<T>): Boolean

Parameters

value
T

The first element in the sequence that passes the test in the specified predicate function.

predicate
Predicate<T>

A function to test each element for a condition.

Returns

Boolean

True if an element in the sequence satiesfies the condition in predicate ; otherwise, False .

Exceptions

predicate is nil .