How to pass arguments to your C# program

To pass arguments to a C# program, all what you need to do is to run the program in command prompt and provide list of arguments in front of program name:

For example:

MyProgram.exe ali noman faisal shahid

In above command 4 arguments as names are passed to the C# program MyProgram.exe

However, sometimes you may want to pass arguments to a C# program without using command line, rather, the arguments should be passed from within the visual studio IDE.

To achieve that, go to top menu, ¬†View, solution explorer. Right click on your project’s name in solution explorer, and click on properties. A Dialog window will appear. In that window, click on Debug under “Application”

You will see a big box with title: “Command line arguments”. This is the place where you will supply the command line arguments of your program.




Add a Comment

Your email address will not be published. Required fields are marked *