1、一維數組(值類型)
- int[] myIntegers; //申明一個數組的引用
- myIntegers = new int[100]; //創建一個含有100個int元素的數據
2、一維數組(引用類型)
- Control[] myControls; //聲明一個數組引用
- myControls = new Control[3]; //創建一個含有3個Control引用的數組
- //注意:以上只創建了3個引用,沒有創建實際的對象。
- myControls[0] = new Button(); //創建對象
- myControls[1] = new TextBox();
- myControls[2] = new ListView();
3、多維數組——矩陣數組
- double[,] myDoubles = new double[10,20]; //二維數組
- string[,,] myStrings = new string[3,4,5]; //三維數組
4、多維數組——鋸齒數組(jagged arrays)
- Point[][] myPonits = new Point[3][];
- myPoints[0] = new Point[10]; //注意這裏同樣只是分配了10個引用,沒有創建對象
- myPoints[1] = new Point[5];
- myPoints[2] = new Point[20];