Correct way to implement C# console application?

后端 未结 5 787
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 21:49

What is the correct way to implement and architect a command line tool as a C# console application?

Concerns to address include proper parsing of command line variab

5条回答
  •  我在风中等你
    2020-12-23 22:34

    As for command line arguments, you'll find various schemes, but I've always been a fan of

    app.exe "self-explanatory arg" /noArgumentSwitch /argumentSwitch="argument"
    

    As for the return code, you can change the signature of your Main() function to return an int rather than void. This will allow you to return a code to the calling process, if necessary.

    As for the error stream, I've never personally used it, and I don't think that it should come at the expense of outputting error information in the standard output stream. It's probably better used for specific error debugging information.

提交回复
热议问题