Compare Skip 5 vs Take 5 in CSharp

Description

The following code shows how to compare Skip 5 vs Take 5.

Example


using System;// w w  w  . ja  v  a2  s. com
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

public class MainClass{
   public static void Main(){
       int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
       var query = numbers.Take(5);
       foreach(var n in query){
           Console.WriteLine(n);
       }
       var query2 = numbers.Skip(5);
       foreach(var n in query2){
           Console.WriteLine(n);
       }

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ