• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • C# 程序員參考--命令行參數教程

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    C# 程序員 參考--命令行參數教程: 本教程展示如何訪問命令行以及訪問命令行參數數組的兩種方法。 教程 下面的示例展示使用傳遞給應用程序的命令行參數的兩種不同方法。 示例 1 本示例演示如何輸出命令行參數。 // cmdline1.cs // arguments: A B C using Sy
    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("Number of command line parameters = {0}",
                 args.Length);
              for(int i = 0; i < args.Length; i++)
              {
                 Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
              }
           }
        }
    輸出
        使用如下所示的一些參數運行程序:cmdline1 A B C。
         輸出將為:
        Number of command line parameters = 3
        Arg[0] = [A]
        Arg[1] = [B]
        Arg[2] = [C]
    示例 2
        循環訪問數組的另一種方法是使用 foreach 語句,如本示例所示。foreach 語句可用于循環訪問數組或“.NET Framework”集合類。它提供了一種簡單的方法來循環訪問集合。
        // cmdline2.cs
        // arguments: 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);
              }
            }
         }
    輸出
        使用如下所示的一些參數運行程序:cmdline2 John Paul Mary。

        輸出將為:
        Number of command line parameters = 3
        John
        Paul
        Mary

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>