Console Application

G

Guest

I am starting to try to write a console application and I have question about
how to launch these type of applications.

I create a "driver" class which will execute the appopriate functionality
based upon and input parameter, but I am not sure I have seen any example of
how to read this value into the program when it launches. So I see it like
this...

At the DOS prompt, I enter "MyApp.exe FileMaint"

Where MyApp.exe is the name of the application and "FileMaint" is the
parameter which is being passed indicating what I want the program to run.

So in the "static void Main" how do I retrieve the value FileMaint?

If I wanted to pass multiple variables, do I seperate by commas?

Lastly, If I am using visual studio to do my development, how do I pass this
parameter to do my testing/development?

Thanks in advance for your assistance!!!
 
K

Kai Brinkmann [MSFT]

1. You can retrieve the command line parameters from the args array in your
main method:

static void main (string[] args) {
// code
}

args[0] is the first parameter, args[1] the second, etc.

2. Use a space to separate your command line parameter, e.g. MyApp.exe
param1 param2

3. To specify the command line parameters for testing/debugging purposes,
right-click on your project in Solution Explorer and choose Properties.
Select Debugging under Configuration Properties and specify the desired
Command Line Arguments in the Start Options section.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top