লিস্টের শেষ Nটি উপাদান উল্টা ক্রমে পেতে Reverse() এবং Take() মেথড চেইন করে ব্যবহার করা হয়।
ব্যাখ্যা
var result = myList.Reverse().Take(3);
Reverse() লিস্ট উল্টা দেয়, তারপর Take(3) প্রথম তিনটি (যা মূলত শেষ তিনটি) নেয়।
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
List myList = new List { "One", "Two", "Three", "Four" };
var res = myList.Reverse().Take(3);
foreach (string s in res) {
Console.WriteLine(s);
}
}
}
আউটপুট
Four Three Two