command line arguments

G

Guest

Hi,

Im a newbie to c#.net 2.0..
I need some info on command line arguments.
how do I pass command line arguments in a console applications..
 
M

Morten Wennevik [C# MVP]

Hi,

You need to have a main method defining a string[] as parameter

public static void Main(string[] args)
{
if(args.Length > 0 && args[0] == "/?")
// write help info
}

any word entered after your program name will be found in 'args'

If you are using Visual Basic, you can also use My.Application.CommandLineArgs any time.
 

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