Javatpoint Logo
Javatpoint Logo

LINQ TAKE PARTITION OPERATOR

In LINQ, Take Operator is used to get the specified number of elements in sequence from the list/collection. The LINQ takes the Operator will return the specified number of elements from the starting of collection or list.

We will pass one parameter to the LINQ Take () operator, which will specify the number of elements to be returned.

Syntax of LINQ Take Operator

The Syntax of LINQ Take operator is to return the specified number of elements from the list/collection.

C# Code,

The Example of LINQ Take Operator in Method Syntax

The example of LINQ Takes () Operator in method syntax to return the specified number of elements from the list or collection.

C# Code

The above program shows that we have a string array that has countries. Here, we want to display the only first three countries from the array. That is why we used the Take operator and passed the count Operator so that it returns the number of elements from the array.

OUTPUT:

LINQ Take Partition Operator

The Example of LINQ Take () Operator in Query Syntax

If we use LINQ Take () operator in query syntax, the example will be like as shown below:

C# Code

OUTPUT:

LINQ Take Partition Operator




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA