Skips elements based on a condition until an element does not satisfy the condition. If the first element itself doesn't satisfy the condition, it then skips 0 elements and returns all the elements in the sequence.
Signature of SkipWhile():
Public static IEnumerable <TSource> SkipWhile<TSource>(this IEnumerable <TSource> source,Func<TSource,bool>,predicate);
Another Over Load Signature:
Public static IEnumerable <TSource> SkipWhile<TSource>(this IEnumerable <TSource> source,Func<TSource,int,bool>,predicate);
Example I:
int[] numbers = { 1, 5, 8, 4, 9, 3, 6, 7, 2, 0 };
var SkipFirstFiveElement = numbers.SkipWhile(n => n < 9);
Output:
It Will return Of element 9,3,6,7,2 and 0.
Example II:
int[] numbers = { 4, 5, 8, 1, 9, 3, 6, 7, 2, 0 };
var indexed = numbers.SkipWhile((n, index) => n > index);
Output:
It Will return Of element 1,9,3,6,7,2 and 0.