কম্পিউটার

C# Link SkipLast Method


শেষ থেকে উপাদানগুলি এড়িয়ে যান এবং 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

  1. C# Linq FirstorDefault পদ্ধতি

  2. C# Linq ইন্টারসেক্ট পদ্ধতি

  3. C# Linq যেখানে পদ্ধতি

  4. C# Linq ডিস্টিনক্ট() পদ্ধতি