ParallelEnumerable.Single 方法
定义
返回并行序列的唯一元素;如果该序列并非恰好包含一个元素,则会引发异常。Returns the only element of a parallel sequence, and throws an exception if there is not exactly one element in the sequence.
重载
Single<TSource>(ParallelQuery<TSource>) |
返回并行序列的唯一元素;如果该序列并非恰好包含一个元素,则会引发异常。Returns the only element of a parallel sequence, and throws an exception if there is not exactly one element in the sequence. |
Single<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>) |
返回并行序列中满足指定条件的唯一元素;如果有多个这样的元素存在,则会引发异常。Returns the only element of a parallel sequence that satisfies a specified condition, and throws an exception if more than one such element exists. |
Single<TSource>(ParallelQuery<TSource>)
返回并行序列的唯一元素;如果该序列并非恰好包含一个元素,则会引发异常。Returns the only element of a parallel sequence, and throws an exception if there is not exactly one element in the sequence.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource Single(System::Linq::ParallelQuery<TSource> ^ source);
public static TSource Single<TSource> (this System.Linq.ParallelQuery<TSource> source);
static member Single : System.Linq.ParallelQuery<'Source> -> 'Source
<Extension()>
Public Function Single(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 single element of.
返回
- TSource
输入序列的单个元素。The single element of 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).
评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.
输入序列包含多个元素。The input sequence contains more than one element. - 或 - 输入序列为空。-or- The input sequence is empty.
另请参阅
适用于
Single<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>)
返回并行序列中满足指定条件的唯一元素;如果有多个这样的元素存在,则会引发异常。Returns the only element of a parallel sequence that satisfies a specified condition, and throws an exception if more than one such element exists.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource Single(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, bool> ^ predicate);
public static TSource Single<TSource> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,bool> predicate);
static member Single : System.Linq.ParallelQuery<'Source> * Func<'Source, bool> -> 'Source
<Extension()>
Public Function Single(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 the single element of.
返回
- TSource
输入序列中满足条件的单个元素。The single element of the input sequence that satisfies a condition.
例外
已使用通过 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.
元素均不满足 predicate
中的条件。No element satisfies the condition in predicate
. -或- 多个元素满足 predicate
中的条件。-or- More than one element satisfies the condition in predicate
.