ArrayExtensions.Last<T>

Extension Method in ArrayExtensions

Declaration

public static T Last<T>(this T[] array)

Description

Returns the last element in the array.

Type Parameters

TThe type of the array.

Parameters

arrayThe array to get the element from.

Returns

TThe last element in the array, or default(T) if the array is empty.

Overload

Declaration

public static T Last<T>(this T[] array, Predicate<T> predicate)

Description

Returns the last element in the array that satisfies a predicate.

Type Parameters

TThe type of the array.

Parameters

arrayThe array to get the element from.
predicateThe predicate to use.

Returns

TThe last element in the array that satisfies the predicate, or default(T) if no element satisfies the predicate.