একটি অ্যারেতে উপাদানগুলিকে বাইপাস করুন এবং SkipWhile() পদ্ধতি ব্যবহার করে অবশিষ্ট উপাদানগুলি ফেরত দিন৷
নিম্নলিখিত আমাদের অ্যারে -
int[] marks = { 45, 88, 55, 90, 95, 85 }; এখন, আসুন 60 এর থেকে বড় বা সমান উপাদানগুলি এড়িয়ে যাই। ল্যাম্বডা এক্সপ্রেশন ব্যবহার করে আমরা যে শর্তটি সেট করেছি।
IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).SkipWhile(s => s >= 60);
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
int[] marks = { 45, 88, 55, 90, 95, 85 };
// skips elements above 60
IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).SkipWhile(s => s >= 60);
// displays rest of the elements
Console.WriteLine("Skipped marks > 60...");
foreach (int res in selMarks) {
Console.WriteLine(res);
}
}
} আউটপুট
Skipped marks > 60... 55 45