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

In LINQ, partition operators are helpful to partition list/collection items into two parts and return one part of list items. The following are the different types of partition operators available in LINQ.

 

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

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 returns a specified number of elements in the sequence. Take
TAKEWHILE This operator returns the elements in a sequence that satisfies the specified condition. TakeWhile
SKIP This operator is used to skip the specified number of elements in a sequence and return the remaining elements. Skip
SKIPWHILE This operator is used to skip elements in sequence based on the condition, which is defined as true. SkipWhile

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