In C# the Main class has string[] args parameter.
What is that for and where does it get used?
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.
From the C# programming guide on MSDN:
The parameter of the Main method is a String array that represents the command-line arguments
So, if I had a program (MyApp.exe) like this:
That I started at the command line like this:
The Main method would be passed an array that contained three strings: ‘Arg1’, ‘Arg2’, ‘Arg3’.
If you need to pass an argument that contains a space then wrap it in quotes. For example:
Command line arguments commonly get used when you need to pass information to your application at runtime. For example if you were writing a program that copies a file from one location to another you would probably pass the two locations as command line arguments. For example: