Skip to content

)} ,--0)}

Qbservable.DefaultIfEmpty(IQbservable) method

Defined in

Type: Qbservable Namespace: System.Reactive.Linq Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static IQbservable<TSource?> DefaultIfEmpty<TSource>(this IQbservable<TSource> source)
  • 2. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source, TSource defaultValue)

1. Overload

public static IQbservable<TSource?> DefaultIfEmpty<TSource>(this IQbservable<TSource> source)

Summary: Returns the elements of the specified sequence or the type parameter's default value in a singleton sequence if the sequence is empty.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence (if any), whose default value will be taken if the sequence is empty.

Parameters

NameTypeDescription
source[IQbservable](#The sequence to return a default value for if it is empty.

Returns: IQbservable -- An observable sequence that contains the default value for the TSource type if the source is empty; otherwise, the elements of the source itself.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.

2. Overload

public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source, TSource defaultValue)

Summary: Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence (if any), and the specified default value which will be taken if the sequence is empty.

Parameters

NameTypeDescription
source[IQbservable](#The sequence to return the specified value for if it is empty.
defaultValueTSourceThe value to return if the sequence is empty.

Returns: IQbservable -- An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.