एक सरणी सेट करें।
int[] arr = { 40, 42, 12, 83, 75, 40, 95 }; 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("Array:");
foreach (int a in arr) {
Console.WriteLine(a);
}
// getting elements above 70
IEnumerable<int> myQuery = arr.AsQueryable() .Where((a, index) => a >= 50);
Console.WriteLine("Elements above 50...:");
foreach (int res in myQuery) {
Console.WriteLine(res);
}
}
} आउटपुट
Array: 40 42 12 83 75 40 95 Elements above 50...: 83 75 95