By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,375 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

Passing command line arguments

P: n/a
How can I pass command line arguments to a C# program?
"C# + command line arguments" is not retrieveing anything useful on Google.

Also, is there a predetermined entry point e.g. 'int main(int argc,
char* argv[]) in C# ?
Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
you declare a:

static void Main(string[] args) {...}
or
static int Main(string[] args) {...}

and the startup args are passed in.

Alternatively, you can get this info from System.Environment

Marc
Jun 27 '08 #2

P: n/a
Hello!

You just use void Main(string[] args)

where args is an array of strings that you can pass into the program

//Tony

"Annonymous Coward" <me@home.comskrev i meddelandet
news:oP*********************@bt.com...
How can I pass command line arguments to a C# program?
"C# + command line arguments" is not retrieveing anything useful on
Google.
>
Also, is there a predetermined entry point e.g. 'int main(int argc,
char* argv[]) in C# ?

Jun 27 '08 #3

P: n/a

"Annonymous Coward" <me@home.comwrote in message
news:oP*********************@bt.com...
How can I pass command line arguments to a C# program?
ProcessStartInfo _info = new ProcessStartInfo("myapplication");
_info.Arguments = string.Format(" --databases
{0} --user={1} --password={2} -h-b", Handler.DatabaseName, Handler.UserID,
Handler.Password);
Process _process = new Process();
_process.StartInfo = _info;
_process.Start();
_process.WaitForExit(10000);

Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.