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. The 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 a result.

 

The following table shows more detailed information related to partition operators in LINQ.

 

OperatorDescriptionQuery Syntax
TAKE This operator is used to return a specified number of elements in the sequence Take
TAKEWHILE This operator is used to return the elements in a sequence which satisfy the specified condition TakeWhile
SKIP This operator is used to skip the specified number of elements in a sequence 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 the coming chapters, we will learn all these partition operators in detail with examples.