C#开发命令执行驱动程序 之 读入命令行参数

/// <summary>
/// 在cmd窗体内执行如下:
/// OrderDriverApp.exe Order Driver App
/// 返回:
/// The args array contains 3 entries!
/// args0 = Order
/// args1 = Driver
/// args2 = App
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
  Console.WriteLine(string.Format("The args array contains {0} entries!", args.Length));

  if (args.Length > 0)
  {
    IEnumerator arrIEnum = args.GetEnumerator();
    int i = 0;
    while (arrIEnum.MoveNext())
    {
      Console.WriteLine(string.Format("args{0} = {1}\n", i, arrIEnum.Current));
      i++;
    }
  }

  Console.ReadKey();
}

posted @ 2017-01-23 22:08  hanhan6494  阅读(257)  评论(0编辑  收藏  举报