System::Collections::Generic::IEnumerable::LINQ_FirstOrDefault method

IEnumerable::LINQ_FirstOrDefault() method

Returns the first element of a sequence, or a default value if the sequence is empty.

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

ReturnValue

First element in the sequence or default-constructed value if the sequence is empty.

See Also

IEnumerable::LINQ_FirstOrDefault(std::function<bool(T)>) method

Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.

T System::Collections::Generic::IEnumerable<T>::LINQ_FirstOrDefault(std::function<bool(T)> predicate)
ParameterTypeDescription
predicatestd::function<bool(T)>A function to test each element for a condition.

ReturnValue

default(T) if source is empty or if no element passes the test specified by predicate; otherwise, the first element in source that passes the test specified by predicate.

See Also