• <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#進階教程(二): 好了,I COME BACK,下面的代碼顯示了我們如何打印多個參數: 000: // CommandLine\cmdline1.cs 001: using System; 002: 003: public class CommandLine 004: { 005: public static void Main(string[] args) 006: { 007: Console.WriteLine(
    C#進階教程(二):   好了,I COME BACK,下面的代碼顯示了我們如何打印多個參數:

    000: // CommandLine\cmdline1.cs
    001: using System;
    002:
    003: public class CommandLine
    004: {
    005: public static void Main(string[] args)
    006: {
    007: Console.WriteLine("Number of command line parameters = {0}", args.Length);
    008: for(int i = 0; i < args.Length; i++)
    009: {
    010: Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
    011: }
    012: }
    013: }

       如果你的輸入為:

       cmdline1 A B C

       那么它的輸出為:

    Number of command line parameters = 3
    Arg[0] = [A]
    Arg[1] = [B]
    Arg[2] = [C]

       哈哈,看出了其中的秘密了吧!是的{0}是一個標記,它告訴系統,這里留下了給第0個參數用,在程序中,這第0個參數就是i.因此,打印出來的就是Arg[0],面不是Arg[{0}]了,哈哈!

       例二向大家展示了foreach這個語句的用法,其實在ASP中,這個經常用到:

    000: // CommandLine\cmdline2.cs
    001: using System;
    002:
    003: public class CommandLine2
    004: {
    005: public static void Main(string[] args)
    006: {
    007: Console.WriteLine("Number of command line parameters = {0}", args.Length);
    008: foreach(string s in args)
    009: {
    010: Console.WriteLine(s);
    011: }
    012: }
    013: }

       很顯然,args是一個數組,而且是字符型的.foreach的意思就是把其中的所有元素都循環完.運行得出:

    >cmdline2 John Paul Mary
    Number of command line parameters = 3
    John
    Paul
    Mary

       好了,同志們,休息一下,我要睡覺了!88,下次再見!

    原文轉自: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>