1. 程式人生 > >C# 列印和for迴圈的使用

C# 列印和for迴圈的使用

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(); //
等待任意字元 } } }