শেষ থেকে উপাদানগুলি এড়িয়ে যান এবং SkipLast() পদ্ধতি ব্যবহার করে অবশিষ্ট উপাদানগুলি ফেরত দিন৷
৷নিম্নলিখিতটি একটি অ্যারে৷
৷int[] marks = { 45, 88, 50, 90, 95, 85 }; এখন, SkipLast() এবং Lambda Expressions ব্যবহার করে শেষ থেকে দুটি উপাদান বাদ দেওয়া যাক, তবে এটি উপাদানগুলিকে অবরোহ ক্রমে সাজানোর পরে করা হয়।
IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).SkipLast(2);
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
int[] marks = { 45, 88, 50, 90, 95, 85 };
IEnumerable<int> selMarks = marks.AsQueryable().OrderByDescending(s => s).SkipLast(2);
Console.WriteLine("Skipped the marks of last two students...");
foreach (int res in selMarks)
Console.WriteLine(res);
}
} আউটপুট
Skipped the marks of last two students... 95 90 88 85