国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

SUNWEN教程之----C#進階(二)

2019-11-18 19:49:54
字體:
來源:轉載
供稿:網友

好了,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,下次再見!

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 揭东县| 方山县| 木里| 桃江县| 探索| 祥云县| 荥经县| 卢湾区| 高雄县| 白山市| 景宁| 武乡县| 米林县| 武乡县| 乌海市| 张家口市| 华坪县| 天气| 新竹县| 伊吾县| 贵州省| 德江县| 闽侯县| 闸北区| 隆昌县| 青州市| 临漳县| 侯马市| 临桂县| 台州市| 苍梧县| 长白| 乌什县| 科技| 右玉县| 屏边| 宾阳县| 临江市| 理塘县| 金沙县| 舒城县|