Method TryLast
- Namespace
- Gamelogic.Extensions.Algorithms
- Assembly
- Gamelogic.Extensions.dll
TryLast<T>(IEnumerable<T>, out T)
Try to get the last element of a sequence, if it exists.
[Version(3, 0, 0)]
public static bool TryLast<T>(this IEnumerable<T> source, out T last)
Parameters
source
IEnumerable<T>The source to get the last element from.
last
TThe last element of the source, if it exists.
Returns
Type Parameters
T
The type of elements in the source.
TryLast<T>(IEnumerable<T>, Func<T, bool>, out T)
Try to get the last element of a sequence that satisfies a predicate, if it exists.
[Version(3, 0, 0)]
public static bool TryLast<T>(this IEnumerable<T> source, Func<T, bool> predicate, out T last)
Parameters
source
IEnumerable<T>The source to get the last element from.
predicate
Func<T, bool>The predicate to test the elements against.
last
TThe last element of the source that satisfies the predicate, if it exists.
Returns
Type Parameters
T
The type of elements in the source.