Take(n) মেথড সিকোয়েন্সের প্রথম n সংখ্যক এলিমেন্ট রিটার্ন করে। OrderByDescending দিয়ে সর্ট করে টপ নম্বর পাওয়া যায়।
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo
{
public static void Main()
{
int[] prod = { 290, 340, 129, 540, 456, 898, 765, 789, 345 };
IEnumerable units = prod.AsQueryable().OrderByDescending(s => s).Take(2);
foreach (int res in units)
Console.WriteLine(res);
}
}
আউটপুট
898 789
Skip(n) দিয়ে প্রথম n টি বাদ দিয়ে বাকিগুলো নেওয়া যায় (পেজিনেশনের জন্য)।