IEnumerable<T>.TryGetSingle Method
Overloads
| TryGetSingle(T) |
Attempts to get the only element in the sequence. |
| TryGetSingle(T, Predicate<T>) |
Attempts to get the only element in the sequence that satisfies a specified condition. |
Attempts to get the only element in the sequence.
Delphi
function TryGetSingle(var value: T): Boolean
Parameters
- value
- T
The single element of the sequence.
Returns
Boolean
True if the sequence contains exactly one element; otherwise, False .
Attempts to get the only element in the sequence that satisfies a specified condition.
Delphi
function TryGetSingle(var value: T; const predicate: Predicate<T>): Boolean
Parameters
- value
- T
The single element of the sequence that satisfies a condition.
- predicate
- Predicate<T>
A function to test an element for a condition.
Returns
Boolean
True if the sequence contains exactly one element that
satisfies the condition in predicate ; otherwise, False .
Exceptions
predicate is nil .