Returns the last element of a parallel sequence that satisfies a condition, or
a default value if no such element is found.
Namespace:
System.Linq
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Shared Function LastOrDefault(Of TSource) ( _
source As ParallelQuery(Of TSource), _
predicate As Func(Of TSource, Boolean) _
) As TSource |
C# |
---|
public static TSource LastOrDefault<TSource>(
ParallelQuery<TSource> source,
Func<TSource, bool> predicate
)
|
Parameters
- source
- Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
The sequence to return an element from.
- predicate
- Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.
Type Parameters
- TSource
- The type of the elements of source.
Return Value
default(
TSource) if the sequence is empty or if no elements pass the test in the
predicate function; otherwise, the last element that passes the test in the predicate function.
Exceptions
Exception | Condition |
---|
System..::.ArgumentNullException |
source or predicate is a null reference (Nothing in Visual Basic).
|
System..::.AggregateException |
One or more exceptions occurred during the evaluation of the query.
|
System..::.OperationCanceledException |
The query was canceled.
|
See Also