OK, I COME back, the following code shows how we can print multiple parameters:
From://Commandline\cmdline1.cs
001:using System;
002:
003:public class CommandLine
004: {
005:public static void Main (string[] args)
006: {
007:console.writeline ("Number of command line parameters = {0}", args. Length);
008:for (int i = 0; i < args. Length; i++)
009: {
010:console.writeline ("arg[{0}] = [{1}]", I, args[i]);
011:}
012:}
013:}
If your input is:
CmdLine1 A B C
Then its output is:
Number of command Line parameters = 3
Arg[0] = [A]
ARG[1] = [B]
ARG[2] = [C]
Haha, see the Secret of it! Yes {0} is a token, it tells the system, here left to the No. 0 parameter, in the program, this No. 0 parameter is I. Therefore, the print is arg[0], the surface is not arg[{0}], haha!
Example two shows you the use of the foreach statement, in fact, in ASP, this is often used:
From://Commandline\cmdline2.cs
001:using System;
002:
003:public class CommandLine2
004: {
005:public static void Main (string[] args)
006: {
007:console.writeline ("Number of command line parameters = {0}", args. Length);
008:foreach (string s in args)
009: {
010:console.writeline (s);
011:}
012:}
013:}
It is clear that args is an array, and it is a character type. The meaning of foreach is to cycle through all the elements. Run:
>cmdline2 John Paul Mary
Number of command Line parameters = 3
John
Paul
Mary
All right, comrades, take a break, I'm going to bed! 88, see you next time!
The above is the Sunwen tutorial----C # Advanced (ii) content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!