I have an application that the user can start with his many arguments.
If I’m not mistaken, I think I can get those execution arguments all over my application.
the application is console application.
tried to google it, but didn’t found how.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can get them using
Environment.CommandLineorEnvironment.GetCommandLineArgs, but I would strongly advise against this. It will make your code harder to test. Instead, parse your command line arguments on start-up into a more semantically meaningful form, and then propagate the relevant options to any code which needs it, potentially through a Dependency Injection framework.That way you’ll end up making it much clearer which pieces of your code rely on which options, and you’ll also be able to write unit tests for those classes without using any global state. All your command line parsing and validation will be in a single place, too.