Home All Groups Group Topic Archive Search About

command line arguments

Author
10 Apr 2007 1:02 PM
AVL
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..

Author
10 Apr 2007 2:50 PM
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] =3D=3D "/?")
        // 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.CommandLi=
neArgs any time.

-- =

Happy coding!
Morten Wennevik [C# MVP]

AddThis Social Bookmark Button