//myArray[0..5] 这是切分myArray数组,取的索引为0-5的数据
foreach (var item in myArray[0..5])
var myarr = new string[] { "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" };
//提取数组myarr的前3个元素
var reult = myarr[0..3];
//使用linq提取
var result = myarr.Skip(0).Take(3);
--------输出结果:10/20/30--------
var myarr = new string[] { "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" };
//提取myarr中倒数第二个元素和倒数第三个元素
var result = myarr[^3..^1];
//使用linq提取
var result = myarr.Skip(myarr.length-3).Take(2);
--------输出结果:80/90--------
var myarr = new string[] { "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" };
//提取myarr中索引index=4、5、6的3个元素
var result = myarr[4..7];
//使用linq提取
var result = myarr.Skip(4).Take(3);
--------输出结果:50/60/70--------
var myarr = new string[] { "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" };
//提取myarr的最后3个元素
var result = myarr[^3..];
//使用linq提取
var result = myarr.Skip(myarr.length-3);
--------输出结果:80/90/100--------