Passing argument to Main method in Visual Studio

To pass arguments to Main method in Visual Studio we can go to the following path:

Right-click on project → Properties → Debug tab → Application arguments

We can write down new arguments there:

Debug tab – Application arguments

And we can use our added arguments with args[] and the appropriate index e.g. args[0], args[1]:

Main(string[] args) method and using arguments
The result of the method with the displayed argument values

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: