Partitioning Operator - Skip


The Skip operator skips a given number of elements from a sequence and then yields the remainder of the sequence.


This example uses Skip to get all but the first 4 elements of the array.


 








using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication4

{

   class Program

  {

    static void Main(string[] args)

    {

     int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };


     var allButFirst4Numbers = numbers.Skip(4);


     Console.WriteLine("All but first 4 numbers:");

     foreach (var n in allButFirst4Numbers)

     {

      Console.WriteLine(n);

      }


      Console.ReadLine();

    }

  }

}



Output:


                    

Aspnet Related Tutorials

...more

New Aspnet Resources

...more

Copyright © 2012 VisualBuilder. All rights reserved