- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
Skip method in C#
Use the Skip() method in C# to skip number of elements in an array.
Let’s say the following is our array −
int[] arr = { 10, 20, 30, 40, 50 };
To skip the first two elements, use the Skip() method and add argument as 2 −
arr.Skip(2);
Let us see an example −
Example
using System.IO; using System; using System.Linq; public class Demo { public static void Main() { int[] arr = { 10, 20, 30, 40, 50 }; Console.WriteLine("Initial Array..."); foreach (var res in arr) { Console.WriteLine(res); } // skipping first two elements var ele = arr.Skip(2); Console.WriteLine("New Array after skipping elements..."); foreach (var res in ele) { Console.WriteLine(res); } } }
Output
Initial Array... 10 20 30 40 50 New Array after skipping elements... 30 40 50
Advertisements