开发者

Console Application input parameters - string identification

开发者 https://www.devze.com 2023-03-19 06:19 出处:网络
I have a console app that takes in string parameters. The app runs through the command line like so: C:\\ExampleApp.exe this is a \"test\"

I have a console app that takes in string parameters. The app runs through the command line like so:

C:\ExampleApp.exe this is a "test"

In the above example, there are 4 different strings read in as paramet开发者_开发问答ers.. Is there any way to determine which parameter had quotes around it? When I do a Console.WriteLine(args[3]), it prints out as test and not "test".


Environment.CommandLine returns a complete command line as a single string, just parse it and you will get the original parameters, quoted or not.


As far as I know the quotes are stripped by the framework before beeing passed to your main function, have you tried to escape the qoutes using a backslash?

0

精彩评论

暂无评论...
验证码 换一张
取 消