Ldg*_*Ldg 7 c# parameters process
我刚刚创建了一个使用以下代码启动进程的应用程序
string [] args = {"a", "b"};
             Process.Start ("C: \ \ demo.exe" String.Join ("", args));
我希望能够将此应用程序中的参数传递给我已启动的进程.
我必须在我启动的流程项目中输入参数?我试着把它们放进去
static void Main (string [] args) {...
但它们没有其他形式.谢谢您的帮助
Rob*_*ert 15
Process p= new Process();
p.StartInfo.FileName = "demo.exe";
p.StartInfo.Arguments = "a b";
p.Start();
要么
Process.Start("demo.exe", "a b");
在demo.exe中
static void Main (string [] args)
{
  Console.WriteLine(args[0]);
  Console.WriteLine(args[1]);
}
你问过如何保存这些参数.您可以使用静态属性创建新类,并在那里保存这些参数.
class ParamHolder
{
  public static string[] Params { get; set;}
}
在主要的
static void Main (string [] args)
{
  ParamHolder.Params = args;
}
在程序的任何地方使用params:
Console.WriteLine(ConsoleParamHolder.Params[0]);
Console.WriteLine(ConsoleParamHolder.Params[1]);
等等