How can I read the command line of a C # application for the console, how was it printed?

I am writing a small console REPL application, and I read the command, split it, and used the switch-poor switch statement to decide which method to invoke (instead of using the strategy template). Then I put each command in the history for audit.

The command line when the application starts, as indicated, is lost because it is already split. I would prefer to have the whole command line and continue working with my loop and have my own split procedure.

Is it possible to somehow get the whole command line?

+5
source share
2 answers

You can get the entire command line that was originally passed to the program through

Environment.CommandLine

+7

, :

var arg = string.Join(" ", args);

, :

Environment.GetCommandLineArgs()
+1

All Articles