JL.*_*JL. 12 c# command-line winforms
我想要一个包含UI的Windows窗体应用程序,但我希望它从命令行运行一些参数,可能还有一个/hide或/visible=false选项.
如何读取命令行参数?并相应调整?
Ste*_*ins 27
如果更改此默认主签名:
[STAThread]
static void Main()
Run Code Online (Sandbox Code Playgroud)
对此:
[STAThread]
static void Main(String[] args)
Run Code Online (Sandbox Code Playgroud)
您可以像访问普通控制台应用程序一样访问命令行变量,或者如果要从其他地方访问它们,可以使用:
System.Environment.GetCommandLineArgs();
Run Code Online (Sandbox Code Playgroud)
[STAThread]
static void Main(string[] args)
{
if (args.Length == 0)
{
// Run the application in a windows form
Application.Run(new MainForm( ));
}
else
{
// Run app from CLI
Console.WriteLine(DoStuff(args));
}
}Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6301 次 |
| 最近记录: |