ImmutableArrayExtensions.Single 方法

定义

重载

Single<T>(ImmutableArray<T>)

返回序列的唯一元素;如果该序列并非恰好包含一个元素,则会引发异常。Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.

Single<T>(ImmutableArray<T>, Func<T,Boolean>)

返回序列中满足指定条件的唯一元素;如果有多个这样的元素存在,则会引发异常。Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.

Single<T>(ImmutableArray<T>)

返回序列的唯一元素;如果该序列并非恰好包含一个元素,则会引发异常。Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T Single(System::Collections::Immutable::ImmutableArray<T> immutableArray);
public static T Single<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray);
static member Single : System.Collections.Immutable.ImmutableArray<'T> -> 'T
<Extension()>
Public Function Single(Of T) (immutableArray As ImmutableArray(Of T)) As T

类型参数

T

集合包含的元素的类型。The type of element contained by the collection.

参数

immutableArray
ImmutableArray<T>

要从中检索元素的数组。The array to retrieve the element from.

返回

T

序列中的元素。The element in the sequence.

Single<T>(ImmutableArray<T>, Func<T,Boolean>)

返回序列中满足指定条件的唯一元素;如果有多个这样的元素存在,则会引发异常。Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T Single(System::Collections::Immutable::ImmutableArray<T> immutableArray, Func<T, bool> ^ predicate);
public static T Single<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray, Func<T,bool> predicate);
static member Single : System.Collections.Immutable.ImmutableArray<'T> * Func<'T, bool> -> 'T
<Extension()>
Public Function Single(Of T) (immutableArray As ImmutableArray(Of T), predicate As Func(Of T, Boolean)) As T

类型参数

T

集合包含的元素的类型。The type of element contained by the collection.

参数

immutableArray
ImmutableArray<T>
predicate
Func<T,Boolean>

返回

T

返回 BooleanReturns Boolean.

适用于