LINQ Partition Operators (Take, Skip, TakeWhile, SkipWhile)

In LINQ, partition operators are used to partition list / collection items into two parts and return one part of list items. Following are the different type of partition operators available in LINQ.

 

  1. TAKE
  2. TAKEWHILE
  3. SKIP
  4. SKIPWHILE

By using these partition operators we can partition list / collection items into two parts and return one part of list items as result.

 

Following table shows the more detailed information related to partition operators in LINQ.

 

OperatorDescriptionQuery Syntax
TAKE This operator is used to return specified number of elements in sequence Take
TAKEWHILE This operator is used to return the elements in sequence which satisfy the specified condition TakeWhile
SKIP This operator is used to skip specified number of elements in squence and return remaining elements Skip
SKIPWHILE This operator is used to skip elements in sequence based on the condition which is defined true SkipWhile

In coming chapters we will learn all these partition operators in detail with examples.