Jump to content
  • Advertisement
Sign in to follow this  
TeSsL

static void Main(string[] args)

This topic is 3348 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by TeSsL
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?


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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!