Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New B - when and why to use: string[] args in Main method

Status
Not open for further replies.

Gzk2010

Programmer
Aug 17, 2010
48
US
I am new and was assuming it is cuase I am at some points sending a string into main. Thing is when I get code snippets from the net they seem to have
static void Main(string[] args) and I remove the string[] args and just make it Main(){...} and their code example works fine. SO when exactly is the
Code:
Main(string[] args)
needed?


Example of a peice of code I am working with that works fine just as Main(){...}
Code:
static void Main(string[] args)
        {

            Thread Thread1 = new Thread(new ThreadStart(Headlights));
            Thread1.Start();
            Thread1.Join(); .......
 
string[] args" would be used when you are passing parameters to the program from the command line. If we were to want to pass what file to copy and what to call it:

copyfile inputfile outputfile

It would be up to you to code how to handle the parameters themselves however.

Walt
Ciber/NES
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top