TryGetFirst()

System::Collections::Generic::Details::TryGetFirst(IEnumerable<T>&, bool&) function

Tries to get the first element of the collection.

template<typename T> T System::Collections::Generic::Details::TryGetFirst(IEnumerable<T> &enumerable, bool &found)

Template parameters

ParameterDescription
TThe type of the collection elements.

Arguments

ParameterTypeDescription
enumerableIEnumerable<T>&The collection from which an element is to be acquired.
foundbool&The output parameter. Returns true when the collection contains any element. Otherwise false is returned.

Return Value

Returns the first collection element. The default value of the type will be returned when the collection is empty.

System::Collections::Generic::Details::TryGetFirst(IEnumerable<T>&, const Func<T, bool>&, bool&) function

Tries to get the first element of the collection, which satisfies to the predicate function.

template<typename T> T System::Collections::Generic::Details::TryGetFirst(IEnumerable<T> &enumerable, const Func<T, bool> &predicate, bool &found)

Template parameters

ParameterDescription
TThe type of the collection elements.

Arguments

ParameterTypeDescription
enumerableIEnumerable<T>&The collection from which an element is to be acquired.
predicateconst Func<T, bool>&The predicate function.
foundbool&The output parameter. Returns true when the collection contains any element. Otherwise false is returned.

Return Value

Returns the first collection element. The default value of the type will be returned when no element satisfying the specified predicate function is found.

See Also