ImmutableArrayExtensions.Single Method

Definition

Overloads

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>)

Source:
ImmutableArrayExtensions.cs
Source:
ImmutableArrayExtensions.cs
Source:
ImmutableArrayExtensions.cs
Source:
ImmutableArrayExtensions.cs

Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.

C#
public static T Single<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray);

Type Parameters

T

The type of element contained by the collection.

Parameters

immutableArray
ImmutableArray<T>

The array to retrieve the element from.

Returns

T

The element in the sequence.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)
UWP 10.0

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

Source:
ImmutableArrayExtensions.cs
Source:
ImmutableArrayExtensions.cs
Source:
ImmutableArrayExtensions.cs
Source:
ImmutableArrayExtensions.cs

Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.

C#
public static T Single<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, Func<T,bool> predicate);

Type Parameters

T

The type of element contained by the collection.

Parameters

immutableArray
ImmutableArray<T>

The immutable array to return a single element from.

predicate
Func<T,Boolean>

The function to test whether an element should be returned.

Returns

T

Returns Boolean.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)
UWP 10.0