ParallelEnumerable.First 方法
定义
返回并行序列中的第一个元素。Returns the first element of a parallel sequence.
重载
First<TSource>(ParallelQuery<TSource>) |
返回并行序列中的第一个元素。Returns the first element of a parallel sequence. |
First<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>) |
返回并行序列中满足指定条件的第一个元素。Returns the first element in a parallel sequence that satisfies a specified condition. |
First<TSource>(ParallelQuery<TSource>)
返回并行序列中的第一个元素。Returns the first element of a parallel sequence.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource First(System::Linq::ParallelQuery<TSource> ^ source);
public static TSource First<TSource> (this System.Linq.ParallelQuery<TSource> source);
static member First : System.Linq.ParallelQuery<'Source> -> 'Source
<Extension()>
Public Function First(Of TSource) (source As ParallelQuery(Of TSource)) As TSource
类型参数
- TSource
source
的元素类型。The type of the elements of source
.
参数
- source
- ParallelQuery<TSource>
要返回其第一个元素的序列。The sequence to return the first element of.
返回
- TSource
返回指定序列中的第一个元素。The first element in the specified 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).
评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.
source
中不包含任何元素。source
contains no elements.
注解
如果查询未排序,则第一个元素是不确定的。If the query is not ordered, then the first element is non-deterministic. 有关详细信息,请参阅 PLINQ 中的顺序保留。For more information, see Order Preservation in PLINQ.
另请参阅
适用于
First<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>)
返回并行序列中满足指定条件的第一个元素。Returns the first element in a parallel sequence that satisfies a specified condition.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource First(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, bool> ^ predicate);
public static TSource First<TSource> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,bool> predicate);
static member First : System.Linq.ParallelQuery<'Source> * Func<'Source, bool> -> 'Source
<Extension()>
Public Function First(Of TSource) (source As ParallelQuery(Of TSource), predicate As Func(Of TSource, Boolean)) As TSource
类型参数
- TSource
source
的元素类型。The type of the elements of source
.
参数
- source
- ParallelQuery<TSource>
要从中返回元素的序列。The sequence to return an element from.
返回
- TSource
序列中通过指定谓词函数中的测试的第一个元素。The first element in the sequence that passes the test in the specified predicate function.
例外
已使用通过 WithCancellation
传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation
.
source
或 predicate
为 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.
source
中没有元素满足 predicate
中的条件。No element in source
satisfies the condition in predicate
.
注解
如果查询未排序,则第一个元素是不确定的。If the query is not ordered, then the first element is non-deterministic. 有关详细信息,请参阅 PLINQ 中的顺序保留。For more information, see Order Preservation in PLINQ.