Skip
In this chapter you will learn:
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:
- How to use SkipWhile operator
- SkipWhile with filter delegate
- SkipWhile and logic operator
- Filter by index
Home » C# Tutorial » Linq Operators