ParallelEnumerable.DefaultIfEmpty 方法

定义

返回指定的并行序列中的元素;如果序列为空,则返回单一实例集合中的指定值。Returns the elements of the specified parallel sequence or the specified value in a singleton collection if the sequence is empty.

重载

DefaultIfEmpty<TSource>(ParallelQuery<TSource>)

返回指定的并行序列的元素;如果序列为空,则返回单一实例集合中的类型参数的默认值。Returns the elements of the specified parallel sequence or the type parameter's default value in a singleton collection if the sequence is empty.

DefaultIfEmpty<TSource>(ParallelQuery<TSource>, TSource)

返回指定的并行序列中的元素;如果序列为空,则返回单一实例集合中的指定值。Returns the elements of the specified parallel sequence or the specified value in a singleton collection if the sequence is empty.

DefaultIfEmpty<TSource>(ParallelQuery<TSource>)

返回指定的并行序列的元素;如果序列为空,则返回单一实例集合中的类型参数的默认值。Returns the elements of the specified parallel sequence or the type parameter's default value in a singleton collection if the sequence is empty.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TSource> ^ DefaultIfEmpty(System::Linq::ParallelQuery<TSource> ^ source);
public static System.Linq.ParallelQuery<TSource> DefaultIfEmpty<TSource> (this System.Linq.ParallelQuery<TSource> source);
static member DefaultIfEmpty : System.Linq.ParallelQuery<'Source> -> System.Linq.ParallelQuery<'Source>
<Extension()>
Public Function DefaultIfEmpty(Of TSource) (source As ParallelQuery(Of TSource)) As ParallelQuery(Of TSource)

类型参数

TSource

source 的元素类型。The type of the elements of source.

参数

source
ParallelQuery<TSource>

序列为空时返回默认值的序列。The sequence to return a default value for if it is empty.

返回

ParallelQuery<TSource>

如果 source 为空,则为包含 default(TSource) 的序列;否则为 sourceA sequence that contains default(TSource) if source is empty; otherwise, source.

例外

source 为 null 引用(在 Visual Basic 中为 Nothing)。source is a null reference (Nothing in Visual Basic).

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

另请参阅

DefaultIfEmpty<TSource>(ParallelQuery<TSource>, TSource)

返回指定的并行序列中的元素;如果序列为空,则返回单一实例集合中的指定值。Returns the elements of the specified parallel sequence or the specified value in a singleton collection if the sequence is empty.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TSource> ^ DefaultIfEmpty(System::Linq::ParallelQuery<TSource> ^ source, TSource defaultValue);
public static System.Linq.ParallelQuery<TSource> DefaultIfEmpty<TSource> (this System.Linq.ParallelQuery<TSource> source, TSource defaultValue);
static member DefaultIfEmpty : System.Linq.ParallelQuery<'Source> * 'Source -> System.Linq.ParallelQuery<'Source>
<Extension()>
Public Function DefaultIfEmpty(Of TSource) (source As ParallelQuery(Of TSource), defaultValue As TSource) As ParallelQuery(Of TSource)

类型参数

TSource

source 的元素类型。The type of the elements of source.

参数

source
ParallelQuery<TSource>

序列为空时返回指定值的序列。The sequence to return the specified value for if it is empty.

defaultValue
TSource

序列为空时要返回的值。The value to return if the sequence is empty.

返回

ParallelQuery<TSource>

如果 source 为空,则为包含 defaultValue 的序列;否则为 sourceA sequence that contains defaultValue if source is empty; otherwise, source.

例外

source 为 null 引用(在 Visual Basic 中为 Nothing)。source is a null reference (Nothing in Visual Basic).

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

另请参阅

适用于