学习获取终端输入的参数并且打印,以及使用循环。

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("Number of command line parameters = {0}",
          args.Length);
       for(int i = 0; i < args.Length; i++)  // 循环
       {
           Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
       }
   }
}

 

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);
       }
   }
}

 

相关文章:

  • 2021-06-20
  • 2021-06-02
  • 2021-11-12
  • 2021-08-07
  • 2021-12-19
  • 2021-05-25
猜你喜欢
  • 2021-11-03
  • 2021-05-17
  • 2021-06-30
  • 2021-03-31
  • 2021-11-15
  • 2021-12-05
  • 2021-10-23
相关资源
相似解决方案