C#中的命令行参数
如果要通过命令行传递参数,请在C#中使用命令行参数-
当我们使用c#创建程序时,将使用staticvoidmain,并且可以在其中看到参数。
class HelloWorld {
static void Main(string[] args) {
/* my first program in C# */
Console.WriteLine("Hello World");
Console.ReadKey();
}string[]args是一个变量,具有从命令行传递的所有值,如上所示。
现在要打印这些参数,假设我们有一个参数“One”-
Console.WriteLine("Length of the arguments: "+args.Length);
Console.WriteLine("Arguments:");
foreach (Object obj in args) {
Console.WriteLine(obj);
}上面将打印-
Length of the arguments: 1 Arguments: One
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短