Skip to ignore the first x elements and outputs the rest in CSharp
Description
The following code shows how to skip to ignore the first x elements and outputs the rest.
Example
using System;/*from w w w . jav a 2s.co m*/
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 }
foreach(var n in lastTwo){
Console.WriteLine(n);
}
}
}
The code above generates the following result.