यदि आप सरणी में कई तत्वों को छोड़ना चाहते हैं, तो C# में Skip() मेथड का उपयोग करें।
मान लीजिए निम्नलिखित हमारी सरणी है:
int[] arr = { 24, 40, 55, 62, 70, 82, 89, 93, 98 };अब पहले चार तत्वों को छोड़ने के लिए:
var ele = arr.Skip(4);
आइए पूरा उदाहरण देखें:
उदाहरण
using System.IO; using System; using System.Linq; public class Demo { public static void Main() { int[] arr = { 24, 40, 55, 62, 70, 82, 89, 93, 98 }; Console.WriteLine("प्रारंभिक सरणी..."); foreach (var res in arr) { Console.WriteLine(res); } // पहले चार तत्वों को छोड़ना var ele = arr.Skip(4); Console.WriteLine("तत्वों को छोड़ने के बाद नई सरणी..."); foreach (var res in ele) { Console.WriteLine(res); } } }आउटपुट
प्रारंभिक सरणी... 24 40 55 62 70 82 89 93 98 तत्वों को छोड़ने के बाद नई सरणी... 70 82 89 93 98