static void Main(string[] args)
When you run your program from the command line, like "myProgram -flag1 -flag2", args[] will contain "-flag1" and "-flag2". It is used for example if you want the user to be able to specify a file-name or something that will be used by your program.
it's everything passed to you application on the commande line or with a shortcut.
ex: myprogram.exe /swith1 /switch2
args[0] = myprogram.exe
args[1] = /switch1
args[2] = /switch2
ex: myprogram.exe /swith1 /switch2
args[0] = myprogram.exe
args[1] = /switch1
args[2] = /switch2
Quote:Original post by matchu
it's everything passed to you application on the commande line or with a shortcut.
ex: myprogram.exe /swith1 /switch2
args[0] = myprogram.exe
args[1] = /switch1
args[2] = /switch2
In the case of C# the program name is not the first argument passed.
eh.. also i am trying to run a program with visual studio. But it does not respond. How do i track which statement is it stuck at?
Quote:Original post by Erik Rufelt
When you run your program from the command line, like "myProgram -flag1 -flag2", args[] will contain "-flag1" and "-flag2". It is used for example if you want the user to be able to specify a file-name or something that will be used by your program.
but i just do the normal run after building. But how come the args.length is 2?
Quote:Original post by TeSsL
eh.. also i am trying to run a program with visual studio. But it does not respond. How do i track which statement is it stuck at?
by running it in the debugger and pressing Shift+F5 to stop running the program. You should also learn the other debugger options/commands at your disposal.
Quote:Original post by TeSsLQuote:Original post by Erik Rufelt
When you run your program from the command line, like "myProgram -flag1 -flag2", args[] will contain "-flag1" and "-flag2". It is used for example if you want the user to be able to specify a file-name or something that will be used by your program.
but i just do the normal run after building. But how come the args.length is 2?
Set a breakpoint at the start of the program and look at the locals window and you would see what is being passed to args.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement