c#之第三课

时间:2015-05-01 22:25:05   收藏:0   阅读:350

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

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

 

原文:http://www.cnblogs.com/lee0oo0/p/4471263.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!