কম্পিউটার টিউটোরিয়াল

সি শার্প Linq Where মেথড

Where মেথডটি একটি প্রিডিকেটের ভিত্তিতে মানগুলির একটি অ্য্রে ফিল্টার করে।

এখানে, প্রিডিকেটটি ৭০-এর উপরের উপাদানগুলোর জন্য যাচাই করছে।

Where((n, index) => n >= 70);

উদাহরণ

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("অ্যরে:"); 
        foreach (int a in arr) 
            Console.WriteLine(a); 
        // ৭০-এর উপরের উপাদানগুলো পাচ্ছি 
        IEnumerable myQuery = arr.AsQueryable().Where((n, index) => n >= 70); 
        Console.WriteLine("৭০-এর উপরের উপাদানগুলো...:"); 
        foreach (int res in myQuery) 
            Console.WriteLine(res); 
    } 
}

আউটপুট

অ্যরে:
10
30
20
15
90
85
40
75
৭০-এর উপরের উপাদানগুলো...:
90
85
75
  1. C# LINQ FirstOrDefault পদ্ধতি

  2. C# LINQ Intersect পদ্ধতি

  3. সি শার্প LINQ-এ একাধিক Where ক্লজ

  4. সি শার্প Linq Distinct() মেথড