我正在编写一个.NET类,需要解析进程的命令行。我不想让Main()方法和该类之间产生依赖关系。该类如何访问命令行?
我正在编写一个.NET类,需要解析进程的命令行。我不想让Main()方法和该类之间产生依赖关系。该类如何访问命令行?我正在编写一个.NET类,需要解析进程的命令行。我不想让Main()方法和该类之间产生依赖关系。该类如何访问命令行?
我正在编写一个.NET类,需要解析进程的命令行。我不想让Main()方法和该类之间产生依赖关系。该类如何访问命令行?调用 Environment.GetCommandLineArgs()
。
[MTAThread]
static void Main(String[] commandLineArguments)
{
CommandLineHelper.parse(commandLineArguments);
}
public static class CommandLineHelper
{
public static void parse(String[] commandLineArguments) {
// add your code here
}
}
String[] myStr = Environment.GetCommandLineArgs();
这行代码获取命令行参数的字符串数组。
最好完整地展示示例。
System.Diagnostics.Process.GetCurrentProcess().StartInfo.Arguments
Environment.GetCommandLineArgs()
调用 CustomConfigClass.Create()
方法,在任何时间之后初始化该类。