C#程序跳过数组中的初始元素
如果要跳过数组中的许多元素,请使用Skip()C#中的方法。
假设以下是我们的数组-
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("Initial Array...");
foreach (var res in arr) {
Console.WriteLine(res);
}
//跳过前四个元素
var ele = arr.Skip(4);
Console.WriteLine("New Array after skipping elements...");
foreach (var res in ele) {
Console.WriteLine(res);
}
}
}输出结果
Initial Array... 24 40 55 62 70 82 89 93 98 New Array after skipping elements... 70 82 89 93 98
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短