Table of Contents

Method TrySingle

Namespace
Gamelogic.Extensions.Algorithms
Assembly
Gamelogic.Extensions.dll

TrySingle<T>(IEnumerable<T>, out T)

Tries to retrieve the single element from the source collection.

[Version(3, 2, 0)]
public static bool TrySingle<T>(this IEnumerable<T> source, out T result)

Parameters

source IEnumerable<T>

The source collection to retrieve the element from.

result T

The single element from the source collection, if it exists.

Returns

bool

True if the source collection contains exactly one element, false otherwise. If true, the single element is assigned to the out parameter 'result'.

Type Parameters

T

The type of elements in the source collection.