

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 elements of an array from the end
Declare an array and initialize elements.
int[] marks = { 45, 50, 60, 70, 85 };
Use the SkipLast() method to skip elements of an array from the end.
IEnumerable<int> selMarks = marks.AsQueryable().SkipLast(3);
The elements are skipped and rest of the elements is returned as shown below −
Example
using System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { int[] marks = { 45, 50, 60, 70, 85 }; Console.WriteLine("Array..."); foreach (int res in marks) Console.WriteLine(res); IEnumerable<int> selMarks = marks.AsQueryable().SkipLast(3); Console.WriteLine("Array after skipping last 3 elements..."); foreach (int res in selMarks) Console.WriteLine(res); } }
Output
Array... 45 50 60 70 85 Array after skipping last 3 elements... 45 50
- Related Questions & Answers
- C# Program to return specified number of elements from the end of an array
- C# Program to skip initial elements in an array
- C# Program to skip a specified number of elements of an array
- Shifting certain elements to the end of array JavaScript
- Removing an element from the end of the array in Javascript
- PHP program to find missing elements from an array
- Python program to left rotate the elements of an array
- Python program to print the duplicate elements of an array
- Python program to right rotate the elements of an array
- Java program to find the sum of elements of an array
- How to delete elements from an array?
- C# Program to skip elements from a sequence as long as the specified condition is true
- C# program to create a List with elements from an array
- C program to reverse an array elements
- Program to find maximum product of two distinct elements from an array in Python
Advertisements