एक सरणी सेट करें।
int[] arr = { 40, 42, 12, 83, 75, 40, 95 };Where क्लॉज और प्रिडिकेट का उपयोग करके 50 से ऊपर के तत्व प्राप्त करें।
IEnumerable<int> myQuery = 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); } // 70 से ऊपर के तत्व प्राप्त करना IEnumerable<int> myQuery = arr.AsQueryable() .Where((a, index) => a >= 50); Console.WriteLine("50 से ऊपर के तत्व...:"); foreach (int res in myQuery) { Console.WriteLine(res); } } }आउटपुट
सरणी: 40 42 12 83 75 40 95 50 से ऊपर के तत्व...: 83 75 95