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

定义

返回一个新的可枚举集合,它包含 source 中的元素,但省略了源集合中的 count 个元素。Returns a new enumerable collection that contains the elements from source with the last count elements of the source collection omitted.

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

类型参数

TSource

可枚举集合中的元素的类型。The type of the elements in the enumerable collection.

参数

source
IEnumerable<TSource>

可枚举的集合实例。An enumerable collection instance.

count
Int32

从集合末尾起省略的元素数。The number of elements to omit from the end of the collection.

返回

IEnumerable<TSource>

一个新的可枚举集合,它包含 source 中的元素,但要减去从集合末尾算起的 count 个元素。A new enumerable collection that contains the elements from source minus count elements from the end of the collection.

异常

sourcenullsource is null.

注解

如果 count 不是正数,则此方法返回 source 可枚举集合的相同副本。If count is not a positive number, this method returns an identical copy of the source enumerable collection.

适用于