![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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# Queryable SkipWhile() Method
Bypass elements in an array and return the remaining elements using the SkipWhile() method.
The following is our array −
int[] marks = { 45, 88, 55, 90, 95, 85 };
Now, let’s skip the elements greater than or equal to 60. The condition we have set using Lambda Expression.
IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).SkipWhile(s => s >= 60);
Example
using System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { int[] marks = { 45, 88, 55, 90, 95, 85 }; // skips elements above 60 IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).SkipWhile(s => s >= 60); // displays rest of the elements Console.WriteLine("Skipped marks > 60..."); foreach (int res in selMarks) { Console.WriteLine(res); } } }
Output
Skipped marks > 60... 55 45
Advertisements