c#控制台传递参数的应用程序

Dav*_*vid 0 c# console command-line-arguments

我到目前为止:

ProcessStartInfo procInfo = new ProcessStartInfo(@"C:\a\a.exe");
procInfo.CreateNoWindow = true;
procInfo.Arguments = "01";
procInfo.Arguments = user_number;
procInfo.Arguments = email;
Process.Start(procInfo);
Run Code Online (Sandbox Code Playgroud)

但它只传递一个参数(最后一个被覆盖),如何传递多个参数,控制台上的参数是一个数组,这必然意味着我可以传递多个参数?

Bol*_*ock 6

您将要传递一个以空格分隔的参数字符串:

procInfo.Arguments = "01 " + user_number + " " + email;
Run Code Online (Sandbox Code Playgroud)

同样的事情,使用一种格式:

procInfo.Arguments = string.Format("{0} {1} {2}", "01", user_number, email);
Run Code Online (Sandbox Code Playgroud)