Web design online - Chapter 7 Arrays 267 // allocate and initialize
Chapter 7 Arrays 267 // allocate and initialize elements in row 0 c[ 1 ] = new int[] { 3,4, 5 }; creates integer array c with row 0 (which is an array itself) containing two elements (1 and 2), and row 1containing three elements (3, 4 and 5). The Length property of each sub- array can be used to determine the size of each column. For the jagged array c, the size of the zeroth column is c[0].Length, which is 2. The application in Fig. 7.14 demonstrates the initialization of double-subscripted arrays in declarations and the use of nested for loops to traverse the arrays (i.e., to manipulate each array element). 1 // Fig. 7.14: TwoDimensionalArrays.cs 2 // Initializing two-dimensional arrays. 3 using System; 4 using System.Drawing; 5 using System.Collections; 6 using System.ComponentModel; 7 using System.Windows.Forms; 8 using System.Data; 9 10 public class TwoDimensionalArrays : System.Windows.Forms.Form 11 { 12 private System.Windows.Forms.Button showOutputButton; 13 private System.Windows.Forms.Label outputLabel; 14 15 // Visual Studio .NET generated code 16 17 [STAThread] 18 static void Main() 19 { 20 Application.Run( new TwoDimensionalArrays() ); 21 } 22 23 private void showOutputButton_Click( object sender, 24 System.EventArgs e ) 25 { 26 // declaration and initialization of rectangular array 27 int[,] array1 = newint[,] { { 1, 2, 3 }, { 4, 5, 6 } }; 28 29 // declaration and initialization of jagged array 30 int[][] array2 = new int[ 3 ][]; 31 array2[ 0 ] = newint[] { 1, 2 }; 32 array2[ 1 ] = new int[] { 3 }; 33 array2[ 2 ] = newint[] { 4, 5,6 }; 34 35 outputLabel.Text = “Values in array1 by row aren”; 36 37 // output values in array1 38 for ( int i = 0; i < array1.GetLength( 0 ); i++ ) 39 { 40 for ( int j = 0; j < array1.GetLength( 1 ); j++ ) 41 outputLabel.Text += array1[ i, j ] + " "; Fig. 7.14 Initializing multidimensional arrays. (Part 1 of 2.)
You want to have a cheap webhost for your apache application, then check apache web hosting services.