Ανάγνωση στα Αγγλικά Επεξεργασία

Κοινή χρήση μέσω


AsyncEnumerable.DefaultIfEmpty Method

Definition

Overloads

DefaultIfEmpty<TSource>(IAsyncEnumerable<TSource>)

Returns the elements of the specified sequence or the type parameter's default if the sequence is empty.

DefaultIfEmpty<TSource>(IAsyncEnumerable<TSource>, TSource)

Returns the elements of the specified sequence or the specified value if the sequence is empty.

DefaultIfEmpty<TSource>(IAsyncEnumerable<TSource>)

Source:
DefaultIfEmpty.cs

Returns the elements of the specified sequence or the type parameter's default if the sequence is empty.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource?> DefaultIfEmpty<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source);

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IAsyncEnumerable<TSource>

The sequence to return a default value for if it is empty.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> object that contains the default value for the TSource type if source is empty; otherwise, source.

Exceptions

source is null.

Applies to

.NET 10 και άλλες εκδόσεις
Προϊόν Εκδόσεις
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

DefaultIfEmpty<TSource>(IAsyncEnumerable<TSource>, TSource)

Source:
DefaultIfEmpty.cs

Returns the elements of the specified sequence or the specified value if the sequence is empty.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource> DefaultIfEmpty<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, TSource defaultValue);

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IAsyncEnumerable<TSource>

The sequence to return a default value for if it is empty.

defaultValue
TSource

The value to return if the sequence is empty.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> object that contains the default value for the TSource type if source is empty; otherwise, source.

Exceptions

source is null.

Applies to

.NET 10 και άλλες εκδόσεις
Προϊόν Εκδόσεις
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)