Qbservable.DefaultIfEmpty<TSource> 方法 (IQbservable<TSource>,TSource)

如果序列为空,则返回指定序列的元素或类型参数在单一实例序列中的默认值。

Namespace:System.Reactive.Linq
装配: System.Reactive.Providers.dll) 中的 System.Reactive.Providers (

语法

'Declaration
<ExtensionAttribute> _
Public Shared Function DefaultIfEmpty(Of TSource) ( _
    source As IQbservable(Of TSource), _
    defaultValue As TSource _
) As IQbservable(Of TSource)
'Usage
Dim source As IQbservable(Of TSource)
Dim defaultValue As TSource
Dim returnValue As IQbservable(Of TSource)

returnValue = source.DefaultIfEmpty(defaultValue)
public static IQbservable<TSource> DefaultIfEmpty<TSource>(
    this IQbservable<TSource> source,
    TSource defaultValue
)
[ExtensionAttribute]
public:
generic<typename TSource>
static IQbservable<TSource>^ DefaultIfEmpty(
    IQbservable<TSource>^ source, 
    TSource defaultValue
)
static member DefaultIfEmpty : 
        source:IQbservable<'TSource> * 
        defaultValue:'TSource -> IQbservable<'TSource> 
JScript does not support generic types and methods.

类型参数

  • TSource
    源的类型。

参数

  • defaultValue
    类型:TSource
    序列为空时要返回的值。

返回值

类型: System.Reactive.Linq.IQbservable<TSource>
一个可查询的可观测序列,如果源为空,则包含指定的默认值;否则为源本身的元素。

使用说明

在 Visual Basic 和 C# 中,可以将此方法作为 IQbservable<TSource> 类型的任何对象的实例方法调用。 当使用实例方法语法调用此方法时,请省略第一个参数。 有关详细信息,请参阅

另请参阅

参考

Qbservable 类

DefaultIfEmpty 重载

System.Reactive.Linq 命名空间