C# 陣列
使用時機
當需要使用到大量的記憶空間時, 陣列即是一項選擇. 比如, 想要記錄10個學生的成績, 在前述的方法中, 只能使用 int s1, s2, s3……一直寫到s10.
那如果有100個學生呢, 不就寫到手骨折了.
陣列宣告與建立
陣列為物件(參考型別), 需使用new產生. 如
int [] score;//宣告 score=new int[10];//產生10個空間 以上, 可合伴為 int[] score=new int[10];
請注意 : int score[] 是錯誤的
陣列元素使用
要將陣列裏的10個數字取出列印, 可以使用如下方法.
其中score[i] 的 “i”, 稱為索引(index), 其值為 0~9, 不可超出9, 否則就是超出邊界(Out of Boundle)
for (int i = 0; i < score.Length; i++)
{
Console.WriteLine("{0}", score[i]);
}
二維陣列
假如想要記錄10個學生的國英數三科成績, 此時就需使用二維陣列, 先看下面程式碼

Amazing! Its in fact amazing post, I have got much clear
idea on the topic of from this article.