我有一个用于运行多个报告的应用程序,然后在运行时由命令行参数选择(在计划任务中)。但是,我希望能够在visual studio中手动运行它,然后问我想要运行什么报告。这是我试过的代码:
static void Main(string[] args)
{
var TestVersion = false;
int HeaderRow = 2;
if (args.Length==0)
{
Console.WriteLine("What Report would you like to run?");
args[1] = Console.ReadLine();
}
它在args[1]
行崩溃并出现以下错误:
Index was outside the bounds of the array.
我也试过了args[0]
,但也没有用。我也尝试过将args作为普通字符串传递。我该如何解决这个问题?