Skip

In this chapter you will learn:

  1. How to use use Skip operator
  2. The Skip operator ignores the first x elements and outputs the rest

Get to know Skip operator

Skip discards the first n elements and emits the rest.

using System;/* j  a va2s . com*/
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Program{
    static void Main(){
        string[] names = { "Java", "C#", "Javascript", "SQL", 
                   "Oracle", "Python", "C++", "C", "HTML", "CSS" };

        IEnumerable<string> query = names.Skip(2);
        foreach (string s in query)
        {
            Console.WriteLine(s);
        }
    }
}

The output:

Skip first x elements

using System;/*from  ja  v  a  2  s  .c  om*/
using System.Collections.Generic;
using System.Linq;
public class MainClass {
    public static void Main() {

        int[] numbers = { 10, 9, 8, 7, 6 };
        IEnumerable<int> lastTwo = numbers.Skip(3);     // { 7, 6 }

    }
}

Next chapter...

What you will learn in the next chapter:

  1. How to use SkipWhile operator
  2. SkipWhile with filter delegate
  3. SkipWhile and logic operator
  4. Filter by index
Home » C# Tutorial » Linq Operators
Aggregate
Aggregate with seed
Aggregate string value
All
Any
Average
Cast
Concat
Contains
Count
DefaultIfEmpty
Distinct
ElementAt
ElementAtOrDefault
Empty
Except
FindAll
First
FirstOrDefault
GroupBy
Intersect
Last
LastOrDefault
LongCount
Max
Min
OfType
OrderBy
OrderByDescending
Range
Repeat
Reverse
SelectMany
SequenceEqual
Single
SingleOrDefault
Skip
SkipWhile
Sum
Take
TakeWhile
ThenBy
ThenByDescending
ToArray
ToList
Zip