- 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
C# Program to skip initial elements in an array
If you want to skip a number of elements in an array, then use the Skip() method in C#.
Let’s say the following is our array −
int[] arr = { 24, 40, 55, 62, 70, 82, 89, 93, 98 };
Now to skip first four elements −
var ele = arr.Skip(4);
Let us see the complete example −
Example
using System.IO; using System; using System.Linq; public class Demo { public static void Main() { int[] arr = { 24, 40, 55, 62, 70, 82, 89, 93, 98 }; Console.WriteLine("Initial Array..."); foreach (var res in arr) { Console.WriteLine(res); } // skipping first four elements var ele = arr.Skip(4); Console.WriteLine("New Array after skipping elements..."); foreach (var res in ele) { Console.WriteLine(res); } } }
Output
Initial Array... 24 40 55 62 70 82 89 93 98 New Array after skipping elements... 70 82 89 93 98
Advertisements