![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# Linq Where Method
The Where method filters an array of values based on a predicate.
Here, the predicate is checking for elements above 70.
Where((n, index) => n >= 70);
Example
using System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { int[] arr = { 10, 30, 20, 15, 90, 85, 40, 75 }; Console.WriteLine("Array:"); foreach (int a in arr) Console.WriteLine(a); // getting elements above 70 IEnumerable myQuery = arr.AsQueryable().Where((n, index) => n >= 70); Console.WriteLine("Elements above 70...:"); foreach (int res in myQuery) Console.WriteLine(res); } }
Output
Array: 10 30 20 15 90 85 40 75 Elements above 70...: 90 85 75
Advertisements