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
sourceIEnumerable<T>The source collection to retrieve the element from.
resultTThe 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
TThe type of elements in the source collection.