Enumerable.TakeLast<TSource>(IEnumerable<TSource>, Int32) 方法

定义

返回一个新的可枚举集合,它包含 count 中的最后 source 个元素。

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<TSource> ^ TakeLast(System::Collections::Generic::IEnumerable<TSource> ^ source, int count);
public static System.Collections.Generic.IEnumerable<TSource> TakeLast<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, int count);
static member TakeLast : seq<'Source> * int -> seq<'Source>
<Extension()>
Public Function TakeLast(Of TSource) (source As IEnumerable(Of TSource), count As Integer) As IEnumerable(Of TSource)

类型参数

TSource

可枚举集合中元素的类型。

参数

source
IEnumerable<TSource>

可枚举的集合实例。

count
Int32

从集合末尾算起获取的元素数。

返回

IEnumerable<TSource>

一个新的可枚举集合,它包含 count 中的最后 source 个元素。

例外

sourcenull

注解

如果 count 不是正数,则此方法返回一个空的可枚举集合。

适用于