TakeLast - Kalkwst/Risotto GitHub Wiki
Returns the specified number of contiguous elements from the end of a sequence.
In this page
Overload | Description |
---|---|
TakeLast(int n) | Returns the specified number of contiguous elements from the end of a sequence. |
Returns the specified number of contiguous elements from the end of a sequence.
T
The type of the elements of source
.
source
IEnumerable <TSource>
A sequence to get the n last elements of.
n
Int32
The number of elements to get from the end of the sequence.
IEnumerable <TSource>
The n
last elements of the sequence.
source
is null
n
is negative.
The following code example demonstrates how to use public static IEnumerable TakeLast(int n) to get the last n
elements of a sequence.
var sequence = new[] { 12, 34, 56, 78, 910, 1112 };
var skimmed = sequence.TakeLast(3);
//=> [ 78, 910, 1112 ]