C#访问命令行的两种方法
时间:2020-12-01 12:02:35|栏目:.NET代码|点击: 次
本文实例讲述了C#访问命令行的两种方法。分享给大家供大家参考。具体如下:
方法1:
// 参数:A B C
using System;
public class CommandLine
{
public static void Main(string[] args)
{
// Length 属性用于获取数组的长度。
// 注意,Length 是只读属性:
Console.WriteLine("Number of command line parameters = {0}", args.Length);
for(int i = 0; i < args.Length; i++)
{
Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
}
}
}
方法2:
// 参数:John Paul Mary
using System;
public class CommandLine2
{
public static void Main(string[] args)
{
Console.WriteLine("Number of command line parameters = {0}", args.Length);
foreach(string s in args)
{
Console.WriteLine(s);
}
}
}
希望本文所述对大家的C#程序设计有所帮助。
上一篇:asp.net使用npoi读取excel模板并导出下载详解
栏 目:.NET代码
下一篇:C#函数式编程中的部分应用详解
本文标题:C#访问命令行的两种方法
本文地址:http://www.codeinn.net/misctech/28165.html






