Meaning of static void main (string [] ARGs) in C #
- Static: Declares the main method as static.
- Void: indicates that the main method does not return any content.
- String [] ARGs: this parameter is used to receive input from the command line. String [] indicates that ARGs can store string arrays.
The command window will pop up during running, where you can enter some parameters. String [] ARGs refers to the parameters you enter in the Command window. That is, the command line parameters. ARGs is used to process command line parameters. The command line parameter is the parameter that you pass to the program when running the program. It is optional and not required. 1. Create the console program mainargs.
2. write the code.
Using system; using system. collections. generic; using system. LINQ; using system. text; namespace mainargs {class program {static void main (string [] ARGs) {int argslength = args. length; console. writeline ("length of the main function parameter ARGs:" + argslength. tostring (); For (INT I = 0; I <argslength; I ++) {console. write ("th" + I. tostring () + "bit:"); console. writeline (ARGs [I]. tostring ();} console. readline ();}}}3. Press f5 to generate the mainargs.exe file. 4. Open the command line, enter the path + mainargs a B c d, and enter to view the result.
Meaning of static void main (string [] ARGs) in C #