LINQ – is SkipWhile broken?

It’s not broken. SkipWhile will only skip items in the beginning of the IEnumerable<T>. Once that condition isn’t met it will happily take the rest of the elements. Other elements that later match it down the road won’t be skipped.

int[] sequence = { 3, 3, 1, 1, 2, 3 };
var result = sequence.SkipWhile(i => i == 3); 
// Result: 1, 1, 2, 3

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)