C# Linq Skip() 方法
使用 Skip() 方法跳过元素并返回剩余元素。
下面是一个数组。
int[] marks = { 80, 55, 79, 99 };现在,让我们使用 Lambda 表达式跳过 2 个元素,但这须在按降序排列这些元素之后进行。
IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).Skip(2);
示例
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
int[] marks = { 80, 55, 79, 99 };
IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).Skip(2);
Console.WriteLine("Skipped the result of 1st two students...");
foreach (int res in selMarks) {
console.WriteLine(res);
}
}
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP