简体   繁体   English

测试命令行参数

[英]Testing command line parameters

What is the best way to test a command line parameter from within the Visual Studio C# Express 2010 IDE? 从Visual Studio C#Express 2010 IDE中测试命令行参数的最佳方法是什么? All i see is the "Play" button to start debugging (and running) my program. 我只看到“播放”按钮开始调试(和运行)我的程序。

You could set command line arguments in the properties of the project: 您可以在项目的属性中设置命令行参数:

替代文字

Setting the arguement value in the project properties is good if the values don't change. 如果值不更改,则在项目属性中设置arguement值是很好的。

If you are wanting to test many different command line arguement combinations, going to the Properties window between each run can get very tedious. 如果您想要测试许多不同的命令行争论组合,那么在每次运行之间进入“属性”窗口会变得非常繁琐。 One way to get around this is to place a breakpoint on the { at the start of the Main method and set a debug watch on the command arguments. 要解决这个问题的方法之一是放置一个断点在{在开始Main方法,并设置调试手表上的命令参数。

Then all that is needed is to run the program, wait for it to break and then edit the value of the arguement in the watch window. 然后所需要的只是运行程序,等待它打破,然后在监视窗口中编辑争论的值。 When you continue execution it will be as if you had given those command line arguements. 当你继续执行时,就好像你已经给出了那些命令行争论。

Right click the project in Solution Explorer, select Properties, then the Debug tab. 右键单击Solution Explorer中的项目,选择Properties,然后选择Debug选项卡。 Here you will see a textbox labeled "Command line arguments". 在这里,您将看到一个标有“命令行参数”的文本框。 If you enter any arguments here, they will be passed as command line arguments when you debug, ie. 如果在此处输入任何参数,则在调试时它们将作为命令行参数传递,即。 "hit Play". “点击播放”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM