ParallelEnumerable.Any 方法

定义

确定并行序列是否包含任何元素。Determines whether a parallel sequence contains any elements.

重载

Any<TSource>(ParallelQuery<TSource>)

确定并行序列是否包含任何元素。Determines whether a parallel sequence contains any elements.

Any<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>)

并行确定序列中的任何元素是否都满足条件。Determines in parallel whether any element of a sequence satisfies a condition.

Any<TSource>(ParallelQuery<TSource>)

确定并行序列是否包含任何元素。Determines whether a parallel sequence contains any elements.

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

类型参数

TSource

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

参数

source
ParallelQuery<TSource>

要检查是否为空的序列。The sequence to check for emptiness.

返回

如果源序列包含任何元素,则为 true;否则为 falsetrue if the source sequence contains any elements; otherwise, false.

异常

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

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

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

注解

任何方法的此重载都会导致在返回结果之前执行完全缓冲的合并。This overload of the Any method causes a fully-buffered merge to be performed before the result is returned. 合并行为可能会影响性能或导致大型枚举中出现内存不足异常。The merge behavior can impact performance or cause an out of memory exception in large enumerables. 若要避免合并行为,请使用采用 Func 参数的任何重载,或使用其他方法(如 FirstOrDefault)。To avoid the merge behavior, use the overload of Any that takes a Func parameter, or else use an alternative method such as FirstOrDefault.

另请参阅

Any<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>)

并行确定序列中的任何元素是否都满足条件。Determines in parallel whether any element of a sequence satisfies a condition.

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

类型参数

TSource

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

参数

source
ParallelQuery<TSource>

将对其元素应用谓词的序列。A sequence to whose elements the predicate will be applied.

predicate
Func<TSource,Boolean>

用于测试每个元素是否满足条件的函数。A function to test each element for a condition.

返回

如果源序列中的任何元素都通过指定谓词中的测试,则为 true;否则为 falsetrue if any elements in the source sequence pass the test in the specified predicate; otherwise, false.

异常

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

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

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

另请参阅

适用于