SkipLast() পদ্ধতি ব্যবহার করে শেষ থেকে উপাদান বাদ দিয়ে বাকি উপাদানগুলো ফেরত পান।
নিচে একটি অ্যারে দেওয়া হলো।
int[] marks = { 45, 88, 50, 90, 95, 85 };এখন, SkipLast() এবং ল্যাম্বডা এক্সপ্রেশন ব্যবহার করে শেষ থেকে দুটি উপাদান বাদ দিন, কিন্তু এটি উপাদানগুলো অবরোহক্রমে সাজানোর পরে করা হবে।
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