在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
//myArray[0..5] 这是切分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);
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);
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);
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);
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论