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

定义

返回一个新的可枚举集合,它包含 source 中的元素,但省略了源集合中的 count 个元素。

C#
public static System.Collections.Generic.IEnumerable<TSource> SkipLast<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, int count);

类型参数

TSource

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

参数

source
IEnumerable<TSource>

可枚举的集合实例。

count
Int32

从集合末尾起省略的元素数。

返回

IEnumerable<TSource>

一个新的可枚举集合,它包含 source 中的元素,但要减去从集合末尾算起的 count 个元素。

例外

sourcenull

注解

如果 count 不是正数,则此方法返回可枚举集合的 source 相同副本。

适用于

产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1