在 VS 中通过 Main(string[] args) 传递参数
Pass arguments through Main(string[] args) in VS
当我尝试通过 Visual Studio.
多个项目时,如何通过 Main(string[] args) 传递参数
我通常右键单击该项目并 select:调试 -> 启动新实例。此时我该如何传递参数?
右键单击项目,select属性。在Debug选项卡下,可以传入命令行参数
如果您是 运行 调试人员,则可以通过项目设置更改应用程序的调用方式。
打开 Project Settings
> Debug
,然后设置 Command Line Arguments
。
这是一个控制台应用程序示例
using System;
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < args.Length; i++) // Loop through array
{
Console.WriteLine(args[i]);
}
Console.ReadLine();
}
}
"C:\ConsoleApp1.exe" a b c
输出:
a
b
c
当我尝试通过 Visual Studio.
多个项目时,如何通过 Main(string[] args) 传递参数我通常右键单击该项目并 select:调试 -> 启动新实例。此时我该如何传递参数?
右键单击项目,select属性。在Debug选项卡下,可以传入命令行参数
如果您是 运行 调试人员,则可以通过项目设置更改应用程序的调用方式。
打开 Project Settings
> Debug
,然后设置 Command Line Arguments
。
这是一个控制台应用程序示例
using System;
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < args.Length; i++) // Loop through array
{
Console.WriteLine(args[i]);
}
Console.ReadLine();
}
}
"C:\ConsoleApp1.exe" a b c
输出:
a
b
c