C# 打印和for循環的使用
阿新 • • 發佈:2019-01-12
app tasks cati line for循環 string spa ring div
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7 }; // 定義不定長數組//Length表示獲取長度 for(int i = 0; i < numbers.Length; i++) { // writeLine:表示打印一行;Write:表示不換行打印 Console.WriteLine(numbers[i]); // 打印數組的內容 } // ReadLine:讀取一行,回車結束,返回字符串類型數據;Read:讀取一個字符,回車結束,返回int行數據,貌似是ASCII碼值 Console.ReadKey(); //等待任意字符 } } }
C# 打印和for循環的使用