Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In command line arguments I wrote my arg, but I want to launch my exe from command prompt and pass my I don't want that arg is fixed..

static void Main(string[] args)

            string t = "";

            Form1 y = new Form1();
            y.mia = "";

            if (args.Length > 0)
                y.mia = args[0];

            //t = args[0];
            int uu = 4;


how Must I write in command prompt?

What I have tried:

I wrote my string in debug-->command line arguments but in this way argument is fixed
Updated 30-Mar-23 4:18am
PIEBALDconsult 30-Mar-23 8:47am    
It's called a command line for a reason.

1 solution

You haven't explained what the problem is. Your code already reads the command-line arguments - although it will crash if no arguments are passed. You simply need to pass the argument when you launch it:
C:\Path\To\YourApplication.exe YourFirstArgument
Share this answer
Member 14594285 30-Mar-23 6:03am    
so shouldn't I write argument in box of command line argument in project properties? Must I write it directly in command prompt?
Richard Deeming 30-Mar-23 6:05am    
The argument you specify in the project properties is used when you launch your application from the debugger.

When you launch your application from outside of the debugger, you need to pass the argument via the command-prompt, or in the Windows "run" box.
Member 14594285 30-Mar-23 9:25am    
I improved question
Member 14594285 30-Mar-23 9:19am    
yes, but to pass the argument outside of the debugger and via the command-prompt how must I write in command prompt? I wrote like you said and my program must write argument in a text box and text box is empty...
PIEBALDconsult 30-Mar-23 10:17am    
Then it's a problem in your form code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900