Use of SkipWhile in Linq

Gopesh9
Posted by Gopesh9 under LINQ category on | Points: 40 | Views : 1559
SkipWhile will skip all the elements starting from the beginning of the list until a number is not less than 7, after that it will take all the element.

int[] numbers = { 2, 6, 1, 3, 8, 7, 6, 1, 2, 0 };   
var number = numbers.SkipWhile(n => n < 7);
Console.WriteLine("Numbers Less than 7:");
foreach (var n in number)
{
Console.WriteLine(n);
}

Comments or Responses

Login to post response