सरणी के अंत से तत्व लौटाने के लिए TakeLast() विधि का उपयोग करें।
उदाहरण
पहले सरणी घोषित और आरंभ करें:
int[] prod = { 110, 290, 340, 540, 456, 698, 765, 789 };
अब अंतिम तीन तत्व प्राप्त करें:
IEnumerable<int> units = prod.AsQueryable().TakeLast(3);
पूर्ण कोड
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
int[] prod = { 110, 290, 340, 540, 456, 698, 765, 789 };
// अंतिम तीन उत्पादों का मान
IEnumerable<int> units = prod.AsQueryable().TakeLast(3);
foreach (int res in units) {
Console.WriteLine(res);
}
}
}
आउटपुट
698 765 789