Passing command line arguments in Visual Studio 2010?
186,028
Solution 1
- Right click your project in Solution Explorer and select Properties from the menu
- Go to Configuration Properties -> Debugging
- Set the Command Arguments in the property list.
Solution 2
Under Project->Properties->Debug, you should see a box for Command line arguments (This is in C# 2010, but it should basically be the same place)
Solution 3
Visual Studio 2015:
Project
=>
Your Application Properties
. Each argument can be separated using space. If you have a space in between for the same argument, put double quotes as shown in the example below.
static void Main(string[] args)
{
if(args == null || args.Length == 0)
{
Console.WriteLine("Please specify arguments!");
}
else
{
Console.WriteLine(args[0]); // First
Console.WriteLine(args[1]); // Second Argument
}
}
Solution 4
- Right click on Project Name.
- Select Properties and click.
- Then, select Debugging and provide your enough argument into Command Arguments box.
Note:
- Also, check Configuration type and Platform.
After that, Click Apply and OK.
Author by
Fahad
Updated on April 11, 2020Comments
-
Fahad about 4 years
I am working on a C project and can not figure out how to pass command line arguments to my main function in Visual Studio 2010 Express Edition. I want to debug - how do these command line arguments work?
-
Fahad almost 14 yearsThankyou ! I picked the other guy's answer because he was the first one to answer !
-
Rocket almost 11 years@Andrew Cooper and what if we have 2 argument ? do we need to seprate then with
;
, and we set the path in the normal way like we did in c++ ? -
Andrew Cooper almost 11 years@Ahmad - No. Just type the arguments in like you would on the command line. ie. separated by spaces.
-
Chris Zhang over 10 yearsIs there any way to enter them into the terminal if it's run as a terminal application?
-
Andrew Cooper over 10 years@ChrisZhang I assume you mean a Console Application, and the answer is No.
-
The Beast over 8 years@Andrew Cooper Can you tell me plz how to pass multiple arguments in VS
-
The Beast over 8 years@AlexHart Can you tell me plz how to pass multiple arguments in VS ?
-
Andrew Cooper over 8 years@Frankenstein - Just add them as you would on the command line, separated by spaces
-
The Beast over 8 years@AndrewCooper yes that what i have done but i'm unable to run it under VS however i can run it from command line : please view stackoverflow.com/questions/35196376/…
-
Andrew Cooper almost 8 years@alex yes. It's free-form text. It should be able to take any argument string you'd have on the command line