IEnumerable<T>.Single Method
Overloads
| Single |
Returns the only element of the sequence, and raises an exception if there is not exactly one element in the sequence. |
| Single(Predicate<T>) |
Returns the only element of the sequence that satisfies a specified condition, and raises an exception if more than one such element exists. |
Returns the only element of the sequence, and raises an exception if there is not exactly one element in the sequence.
function Single: T
Returns
The single element of the sequence.
Exceptions
The input sequence contains more than one element.
-or-
The input sequence is empty.
Returns the only element of the sequence that satisfies a specified condition, and raises an exception if more than one such element exists.
function Single(const predicate: Predicate<T>): T
Parameters
- predicate
- Predicate<T>
A function to test an element for a condition.
Returns
The single element of the sequence that satisfies a condition.
Exceptions
predicate is nil .
No element satisfies the condition in predicate .
-or-
More than one element satisfies the condition in predicate .
-or-
The sequence is empty.