How to pass argument command line argument in C#?

Sanchita Agrawal
3 min readJan 8, 2024

--

Hello Everyone😊

It’s been too long since I left writing. Currently I’ve been started learning about C# and .net and few more technologies one by one. So, let’s see this blog. Hope it will be helpful to you!

Before starting we must know that applications are of 3 types :-

Web Application : Applications which we seen running over the google like Gmail and so on.

Window Form Application : These applications runs on desktop i.e. with .exe extension.

Console Application : Applications which runs on console with using command line interface.

Now, passing the arguments in the console app using command line is very basic in building console applications.

For in case software we are using Visual Studio 2022 for Integrated Development Environment(IDE)..

Link 👇👇

Download the community version for free!!😜

Even in today’s UI, we often need a way to start the program with certain parameters. Discussion sentences help provide these boundaries without having to expose everyone. When developing with .NET and C#, you can get the command line from the Main(string[] Args) function. Args is an array containing all space-separated strings entered on the command line.

Steps for passing command line arguments in C# using Visual Studio 2022

Step 1: Create a new project in the visual studio. Now click the Right Mouse Button on the FirstProject which you have created (Project name can be anything). Further right clicking just go to the bottom and choose Properties as shown below in the picture.

Step 2: Noe properties page will open and choose debug option in there and go to general.

Step 3: Now in command line arguments text box write whatever the arguments you want to pass. for example I’ve taken here “Hi, how are you?”

Step 4: Now write for loop program for calling that passed arguments.

--

--

Sanchita Agrawal
0 Followers

Computer Science Major || Software Developer@GenusPower