[英]Get following command line arguments (elements in an array) in C#
How would I get all arguments after the first 3 from a string[]
in C#? 我如何从C#中的
string[]
中获取前三个参数之后的所有参数?
Eg from [1, 2, 3, 4, 5]
I want [4, 5]
例如
[1, 2, 3, 4, 5]
我要[4, 5]
Making sure you have using System.Linq
, you can use this: 确保已
using System.Linq
,可以使用以下命令:
stringArray.Skip(3);
This returns an IEnumerable, which you can traverse. 这将返回一个IEnumerable,您可以遍历它。 If you need an array, you can just:
如果您需要一个数组,则可以:
stringArray.Skip(3).ToArray();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.