एक सरणी घोषित करें और तत्वों को आरंभ करें।
int[] marks = { 45, 50, 60, 70, 85 };सरणी के अंत से तत्वों को छोड़ने के लिए SkipLast() मेथड का उपयोग करें।
IEnumerable<int> selMarks = marks.AsQueryable().SkipLast(3);
तत्वों को छोड़ दिया जाता है और शेष तत्व वापस कर दिए जाते हैं:
उदाहरण
using System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { int[] marks = { 45, 50, 60, 70, 85 }; Console.WriteLine("सरणी..."); foreach (int res in marks) Console.WriteLine(res); IEnumerable<int> selMarks = marks.AsQueryable().SkipLast(3); Console.WriteLine("अंतिम 3 तत्वों को छोड़ने के बाद सरणी..."); foreach (int res in selMarks) Console.WriteLine(res); } }आउटपुट
सरणी... 45 50 60 70 85 अंतिम 3 तत्वों को छोड़ने के बाद सरणी... 45 50