Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 a specified number of elements of an array
The following is our array −
int[] points = { 210, 250, 300, 350, 420};
Use skip() method to skip elements. Add the number as an argument that displays the number of elements to be returned.
IEnumerable<int> skipEle = points.AsQueryable().OrderByDescending(s => s).Skip(3);
Example
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
int[] points = { 210, 250, 300, 350, 420};
Console.WriteLine("Initial array...");
foreach (int res in points)
Console.WriteLine(res);
IEnumerable<int> skipEle = points.AsQueryable().OrderByDescending(s => s).Skip(3);
Console.WriteLine("Skipped 3 elements...");
foreach (int res in skipEle)
Console.WriteLine(res);
}
}
Output
Initial array... 210 250 300 350 420 Skipped 3 elements... 250 210
Advertisements