C# Linq Skip() Method


Skip elements and return the remaining elements using the Skip() method.

The following is an array.

int[] marks = { 80, 55, 79, 99 };

Now, let us skip 2 elements using Lambda Expressions, but this is done after arranging the elements in descending order.

IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).Skip(2);

Example

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);
      }
   }
}

Updated on: 23-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements