ParallelEnumerable.Count 方法

定义

返回并行序列中的元素数量。Returns the number of elements in a parallel sequence.

重载

Count<TSource>(ParallelQuery<TSource>)

返回并行序列中的元素数量。Returns the number of elements in a parallel sequence.

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

返回一个数字,表示在指定的并行序列中满足条件的元素数量。Returns a number that represents how many elements in the specified parallel sequence satisfy a condition.

Count<TSource>(ParallelQuery<TSource>)

返回并行序列中的元素数量。Returns the number of elements in a parallel sequence.

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

类型参数

TSource

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

参数

source
ParallelQuery<TSource>

包含要计数的元素的序列。A sequence that contains elements to be counted.

返回

输入序列中的元素数量。The number of elements in the input sequence.

异常

已使用通过 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).

源中的元素数大于 MaxValueThe number of elements in source is larger than MaxValue. (在这种情况下 InnerException 为 OverflowException)- 或 - 在查询的评估过程中出现了一个或多个异常。(In this case the InnerException is OverflowException) -or- One or more exceptions occurred during the evaluation of the query.

另请参阅

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

返回一个数字,表示在指定的并行序列中满足条件的元素数量。Returns a number that represents how many elements in the specified parallel sequence satisfy a condition.

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

类型参数

TSource

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

参数

source
ParallelQuery<TSource>

包含要计数的元素的序列。A sequence that contains elements to be counted.

predicate
Func<TSource,Boolean>

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

返回

一个数字,表示序列中满足谓词函数条件的元素数量。A number that represents how many elements in the sequence satisfy the condition in the predicate function.

异常

已使用通过 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).

源中的元素数大于 MaxValueThe number of elements in source is larger than MaxValue. (在这种情况下 InnerException 为 OverflowException)- 或 - 在查询的评估过程中出现了一个或多个异常。(In this case the InnerException is OverflowException) -or- One or more exceptions occurred during the evaluation of the query.

另请参阅

适用于