Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
|
Argument |
Type |
|---|---|
|
Source sequence |
|
|
Predicate |
|
TakeWhile enumerates
the input sequence, emitting each item, until the given predicate is
false. It then ignores the remaining elements:
int[] numbers = { 3, 5, 2, 234, 4, 1 };
var takeWhileSmall = numbers.TakeWhile (n => n < 100); // { 3, 5, 2 }
SkipWhile enumerates
the input sequence, ignoring each item until the given predicate is
false. It then emits the remaining elements:
int[] numbers = { 3, 5, 2, 234, 4, 1 };
var skipWhileSmall = numbers.SkipWhile (n => n < 100); // { 234, 4, 1 }
TakeWhile and SkipWhile have no translation to SQL and cause
a runtime error if used in a LINQ-to-db query.