C# LINQ 基础 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

Skip

Skip用于从输入序列中跳过指定数量的元素,返回由序列中剩余元素所组成的新元素。用法如下代码:

static void Main()
{
  int[] grades = { 59, 82, 70, 56, 92, 98, 85 };
  IEnumerable&ltint&gt lowerGrades =
  grades.OrderByDescending(g => g).Skip(3);
  Console.WriteLine("All grades except the top three are:");
  foreach (int grade in lowerGrades)
  {
      Console.WriteLine(grade);
  }
}

运行结果为:

All grades except the top three are:
82
70
59
56