- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make use of both Take and Skip operator together in LINQ C#?
The Take operator is used to return a given number of elements from an array and the Skip operator skips over a specified number of elements from an array.
Skip, skips elements up to a specified position starting from the first element in a sequence.
Take, takes elements up to a specified position starting from the first element in a sequence.
Example 1
class Program{ static void Main(string[] args){ List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 5, 6, 7, 7, 8, 8 }; System.Console.WriteLine(numbers.Count()); var skipRes = numbers.Skip(5); System.Console.WriteLine(skipRes.Count()); Console.ReadLine(); } }
Output
28 23
Example 2
class Program{ static void Main(string[] args){ List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 5, 6, 7, 7, 8, 8 }; System.Console.WriteLine(numbers.Count()); var takeRes = numbers.Take(5); System.Console.WriteLine(takeRes.Count()); Console.ReadLine(); } }
Output
28 5
Example 3
class Program{ static void Main(string[] args){ List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 5, 6, 7, 7, 8, 8 }; System.Console.WriteLine(numbers.Count()); var takeSkipRes = numbers.Skip(10).Take(18); System.Console.WriteLine(takeSkipRes.Count()); Console.ReadLine(); } }
Output
28 18
- Related Articles
- How to make use of both Take and Skip operator together in LINQ C# Programming
- How to make use of Join with LINQ and Lambda in C#?
- C# Linq Skip() Method
- How to use LINQ in C#?
- How to use “not in” query with C# LINQ?
- How to use LINQ to sort a list in C#?
- How to use ‘as’ operator in C#?
- How to use ‘is’ operator in C#?
- How to use Operator Overloading in C#?
- How to use the ?: conditional operator in C#?
- How to use Null Coalescing Operator (??) in C#?
- How to use an assignment operator in C#?
- How to use multiple for and while loops together in Python?
- How to use take() in android PriorityBlockingQueue?
- How to use take() in android ArrayBlockingQueue?

Advertisements