这种行为是C# .NET中的某个特性还是一个bug?
测试应用程序:
测试应用程序:
using System;
using System.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Arguments:");
foreach (string arg in args)
{
Console.WriteLine(arg);
}
Console.WriteLine();
Console.WriteLine("Command Line:");
var clArgs = Environment.CommandLine.Split(' ');
foreach (string arg in clArgs.Skip(clArgs.Length - args.Length))
{
Console.WriteLine(arg);
}
Console.ReadKey();
}
}
}
使用命令行参数运行它:
a "b" "\\x\\" "\x\"
我理解您需要的翻译如下:我收到的结果是:
Arguments:
a
b
\\x\
\x"
Command Line:
a
"b"
"\\x\\"
"\x\"
在传递给方法 Main() 的参数中缺少反斜杠并且未移除引号,除手动解析 Environment.CommandLine
外,有什么正确的解决方法吗?