AsyncEnumerable.LastOrDefaultAsync Method (System.Linq) (original) (raw)
Definition
Namespace:
Assembly:
System.Linq.AsyncEnumerable.dll
Package:
System.Linq.AsyncEnumerable v10.0.0-preview.4.25258.110
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
LastOrDefaultAsync(IAsyncEnumerable, Func<TSource,CancellationToken,ValueTask>, TSource, CancellationToken) | Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. |
---|---|
LastOrDefaultAsync(IAsyncEnumerable, Func<TSource,Boolean>, TSource, CancellationToken) | Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. |
LastOrDefaultAsync(IAsyncEnumerable, TSource, CancellationToken) | Returns the last element of a sequence, or a default value if the sequence contains no elements. |
LastOrDefaultAsync(IAsyncEnumerable, Func<TSource,Boolean>, CancellationToken) | Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. |
LastOrDefaultAsync(IAsyncEnumerable, CancellationToken) | Returns the last element of a sequence, or a default value if the sequence contains no elements. |
LastOrDefaultAsync(IAsyncEnumerable, Func<TSource,CancellationToken,ValueTask>, CancellationToken) | Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. |
LastOrDefaultAsync(IAsyncEnumerable, Func<TSource,CancellationToken,ValueTask>, TSource, CancellationToken)
Source:
Returns the last element of a sequence that satisfies a condition or a default value if no such element is found.
public static System.Threading.Tasks.ValueTask<TSource> LastOrDefaultAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<bool>> predicate, TSource defaultValue, System.Threading.CancellationToken cancellationToken = default);
static member LastOrDefaultAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<bool>> * 'Source * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function LastOrDefaultAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, CancellationToken, ValueTask(Of Boolean)), defaultValue As TSource, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)
Type Parameters
TSource
The type of the elements of source
.
Parameters
defaultValue
TSource
The default value to return if the sequence is empty.
Returns
defaultValue
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
Applies to
LastOrDefaultAsync(IAsyncEnumerable, Func<TSource,Boolean>, TSource, CancellationToken)
Source:
Returns the last element of a sequence that satisfies a condition or a default value if no such element is found.
public static System.Threading.Tasks.ValueTask<TSource> LastOrDefaultAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,bool> predicate, TSource defaultValue, System.Threading.CancellationToken cancellationToken = default);
static member LastOrDefaultAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, bool> * 'Source * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function LastOrDefaultAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, Boolean), defaultValue As TSource, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)
Type Parameters
TSource
The type of the elements of source
.
Parameters
predicate
A function to test each element for a condition.
defaultValue
TSource
The default value to return if the sequence is empty.
Returns
defaultValue
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
Applies to
LastOrDefaultAsync(IAsyncEnumerable, TSource, CancellationToken)
Source:
Returns the last element of a sequence, or a default value if the sequence contains no elements.
public static System.Threading.Tasks.ValueTask<TSource> LastOrDefaultAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, TSource defaultValue, System.Threading.CancellationToken cancellationToken = default);
static member LastOrDefaultAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * 'Source * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function LastOrDefaultAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), defaultValue As TSource, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)
Type Parameters
TSource
The type of the elements of source
.
Parameters
defaultValue
TSource
The default value to return if the sequence is empty.
Returns
defaultValue
if the source sequence is empty; otherwise, the last element in the IAsyncEnumerable.
Exceptions
Applies to
LastOrDefaultAsync(IAsyncEnumerable, Func<TSource,Boolean>, CancellationToken)
Source:
Returns the last element of a sequence that satisfies a condition or a default value if no such element is found.
public static System.Threading.Tasks.ValueTask<TSource?> LastOrDefaultAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,bool> predicate, System.Threading.CancellationToken cancellationToken = default);
static member LastOrDefaultAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, bool> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function LastOrDefaultAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, Boolean), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)
Type Parameters
TSource
The type of the elements of source
.
Parameters
predicate
A function to test each element for a condition.
Returns
The default value of 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
Applies to
LastOrDefaultAsync(IAsyncEnumerable, CancellationToken)
Source:
Returns the last element of a sequence, or a default value if the sequence contains no elements.
public static System.Threading.Tasks.ValueTask<TSource?> LastOrDefaultAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, System.Threading.CancellationToken cancellationToken = default);
static member LastOrDefaultAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function LastOrDefaultAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)
Type Parameters
TSource
The type of the elements of source.
Parameters
Returns
The default value of TSource
if the source sequence is empty; otherwise, the last element in the IAsyncEnumerable.
Exceptions
Applies to
LastOrDefaultAsync(IAsyncEnumerable, Func<TSource,CancellationToken,ValueTask>, CancellationToken)
Source:
Returns the last element of a sequence that satisfies a condition or a default value if no such element is found.
public static System.Threading.Tasks.ValueTask<TSource?> LastOrDefaultAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<bool>> predicate, System.Threading.CancellationToken cancellationToken = default);
static member LastOrDefaultAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<bool>> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function LastOrDefaultAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, CancellationToken, ValueTask(Of Boolean)), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)
Type Parameters
TSource
The type of the elements of source
.
Parameters
Returns
The default value of 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.