LINQ_Single()

IEnumerable::LINQ_Single() method

Returns the single elemet of the sequence and throws an exception if there are zero or more than one element.

T System::Collections::Generic::IEnumerable<T>::LINQ_Single()

Return Value

The single element of the sequence

Exceptions

ExceptionDescription
InvalidOperationExceptionSource sequence is empty or there are more than one element.

IEnumerable::LINQ_Single(const Func<T, bool>&) method

Returns the single elemet of the sequence that satisfies a condition and throws an exception if there are zero or more than one such elements.

T System::Collections::Generic::IEnumerable<T>::LINQ_Single(const Func<T, bool> &predicate)

Arguments

ParameterTypeDescription
predicateconst Func<T, bool>&A function to test each element for a condition.

Return Value

The single element of the sequence

Exceptions

ExceptionDescription
InvalidOperationExceptionSource sequence is empty or there are more than one element that satisfied predicate.

See Also