একটি অ্যরে সেট করুন।
int[] arr = { 40, 42, 12, 83, 75, 40, 95 };
Where ক্লজ এবং প্রিডিকেট ব্যবহার করে ৫০-এর উপরের উপাদানগুলো পান।
IEnumerablemyQuery = arr.AsQueryable() .Where((a, index) => a >= 50);
সম্পূর্ণ কোডটি দেখি −
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
int[] arr = { 40, 42, 12, 83, 75, 40, 95 };
Console.WriteLine("অ্যরে:");
foreach (int a in arr) {
Console.WriteLine(a);
}
// ৭০-এর উপরের উপাদানগুলো পাচ্ছি
IEnumerable myQuery = arr.AsQueryable() .Where((a, index) => a >= 50);
Console.WriteLine("৫০-এর উপরের উপাদানগুলো...:");
foreach (int res in myQuery) {
Console.WriteLine(res);
}
}
}
আউটপুট
অ্যরে: 40 42 12 83 75 40 95 ৫০-এর উপরের উপাদানগুলো...: 83 75 95