Okay, I COME BACK. The following code shows how to print multiple parameters:
000: // CommandLinecmdline1.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
The output is:
Number of command line parameters = 3
Arg [0] = [A]
Arg [1] = [B]
Arg [2] = [C]
Haha, I saw the secret! Yes {0} is a flag. It tells the system that 0th parameters are left for use. In the Program, The 0th parameters are I. therefore, the output is Arg [0], and the surface is not Arg [{0}]. Haha!
Example 2 shows the usage of the foreach statement. In ASP, this statement is often used:
000: // CommandLinecmdline2.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 :}
Obviously, args is an array, and it is nested. foreach means that all the elements in it are cyclically completed. Run the following code:
> Mongoline2 John Paul Mary
Number of command line parameters = 3
John
Paul
Mary
Okay, Comrades. Have a rest. I'm going to bed! 88. Goodbye next time!