Skip() in Linq avoids or skips the given number of elements from the sequence.
Skip() example in Linq
protected void Page_Load(object sender, EventArgs e)
{
var numArr = new int[5];
numArr[0] = 9;
numArr[1] = 6;
numArr[2] = 3;
numArr[3] = 5;
numArr[4] = 2;
var numbers = numArr.Skip(3);
foreach (var number in numbers)
{
Console.WriteLine(number);
}
// Output will be 5, 2
So in above example of skip in linq, we have numArr.Skip(3);, that will skip first three elements from array and print remaining array elements.
0 Comments :
Post a Comment