CSharp - LINQ Skip

Introduction

Skip operator skips a specified number of elements from the input sequence starting from start and yields the rest.

Prototypes

public static IEnumerable<T> Skip<T>(
        this IEnumerable<T> source,
        int count);

Skip operator is passed with an input source sequence and a count that specifies how many input elements should be skipped.

It returns an object that, when enumerated, will skip the first count elements and yield all subsequent elements.

If the value of count is greater than the number of elements in the input sequence, the input sequence will not be enumerated, and the output sequence will be empty.

Exceptions

ArgumentNullException is thrown if the input source sequence is null.

Demo

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class Program/*from  w w  w.j  a  v a2s  .c  o m*/
{
    static void Main(string[] args)
    {
        string[] codeNames = {"Python", "Java", "Javascript", "Bash", "C++", "Oracle"};
        
        IEnumerable<string> items = codeNames.Skip(1);
        
        foreach (string item in items)
          Console.WriteLine(item);

    }
}

Result

The code above skips the first element.