C# Linq Skip() Method

CsharpProgrammingServer Side Programming

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);
      }
   }
}
raja
Published on 14-Sep-2018 15:30:34
Advertisements