
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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
- Related Articles
- Multiple Where clause in C# Linq
- C# Linq Distinct() Method
- C# Linq Intersect Method
- C# Linq FirstorDefault Method
- C# Linq Reverse Method
- C# Linq Select Method
- C# Linq SelectMany Method
- C# Linq Skip() Method
- C# Linq SkipLast Method
- C# Linq Sum() Method
- C# Linq TakeWhile() Method
- C# Linq ThenBy Method
- C# Linq LastorDefault Method
- C# Linq Zip Method
- C# Linq Contains Method

Advertisements