Reputation: 175
How do i pass arguments to through Main(string[] args) when I am trying to run multiple projects through Visual Studio.
I normally right click on the project and select: Debug -> Start new instance. At this point how do I pass arguments?
Upvotes: 3
Views: 10040
Reputation: 491
Here one Console App example
using System;
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < args.Length; i++) // Loop through array
{
Console.WriteLine(args[i]);
}
Console.ReadLine();
}
}
"C:\ConsoleApp1.exe" a b c
OUTPUT:
a
b
c
Upvotes: 1
Reputation: 156958
If you are running with a debugger, you can change the way the application is called through the Project Settings.
Open Project Settings
> Debug
, and set Command Line Arguments
.
Upvotes: 12
Reputation: 2317
Right click the project, select Properties. Under the Debug tab, you can pass in command line arguments
Upvotes: 4