Original source: http://chenyansong4321.blog.163.com/blog/static/7994995620085305482709/
The main function is the entry point for the C # application, and the main function can have four signatures, as follows:
static void Main ()
static void Main (string[] args)
static int Main ()
static int Main (string[] args)
Executing this function is executing the application. And this function has a parameter string[] args, now we're going to pee it.
The parameter of the main function string[] args is a way to receive information from outside the application. This information is specified when the program is run, and the parameter is represented by command-line arguments.
XXXX about command line parameter xxxx
Open a Notepad, you can enter Notepad in the command line window, you can run this program, but you can also enter Notepad MyFile.txt, the result is that the Notepad runtime loads MyFile.txt, and if the file does not exist, Notepad will create the file. And the myfile.txt here is the command-line argument. With the args parameter, you can write a console application that works in the same way.
When the console application is executed, any command-line arguments specified are placed in the args array, which can then be invoked when the application requires it.
Here is an example to illustrate:
class Class1
{
static void Main (string[] args)
{
Console.WriteLine ("{0} command line arguments were specified", args.length);
foreach (String arg in args)
{
Console.WriteLine (ARG);
}
}
}
Then select Properties in the Solution window, select the configuration propertie option, and then select the Debugging (Debug) page, and set the command line arguments that you want in command-line arguments
For example, setting: Anika pingie myfile.txt (separated by "space" between parameters)
Then, when Ctrl+f5 runs this program, it will output Anika Pingie in turn myfile.txt
This should be on the args parameter, have some understanding of it. :-)
====================================================
Project-> (project name) Properties-> Debug-> command-line arguments
1. Execute at command line
Parameters are separated by a space, if the argument has spaces, in double quotes style
Test AA "BB cc" CC
The equivalent of three parameters passed.
2. Add parameters to VS2005
Menu items--Your project Properties--Debugging--Startup options--command line arguments
You can also type your command-line arguments here