C# 程序员参考--命令行参数教程
示例 1
本示例演示如何输出命令行参数.
// cmdline1.cs
// arguments: A B C
using System;
public class CommandLine
{
public static void Main( string[] args )
{
// The Length property is used to obtain the length of the array.
// Notice that Length is a read-only property:
Console.WriteLine( ,
args.Length );
for( int i = 0; i < args.Length; i++ )
{
Console.WriteLine( , i, args[i] );
}
}
}
输出
使用如下所示的一些参数运行程序:cmdline1 A B C.
输出将为:
Number of command line parameters = 3
Arg[0] = [A]
Arg[1] = [B]
Arg[2] = [C]
本示例演示如何输出命令行参数.
// cmdline1.cs
// arguments: A B C
using System;
public class CommandLine
{
public static void Main( string[] args )
{
// The Length property is used to obtain the length of the array.
// Notice that Length is a read-only property:
Console.WriteLine( ,
args.Length );
for( int i = 0; i < args.Length; i++ )
{
Console.WriteLine( , i, args[i] );
}
}
}
输出
使用如下所示的一些参数运行程序:cmdline1 A B C.
输出将为:
Number of command line parameters = 3
Arg[0] = [A]
Arg[1] = [B]
Arg[2] = [C]