c# treats multidimensional arrays as "arrays of arrays".Simplest form of multidimensional array is 2-dimensional array.
2-dimensional array is declared as:
int[ , ] Array_name=new int[rows,columns]; //rectangular array
eg:
int[ , ] array=new int[3,3];
second is variable size arrays that are knows as jagged arrays.
The jagged array is two dimensional array having different length for each row.It can be declared as:
int[ ][ ] array_name=new [row][column];
eg:
int[ ][ ] array=new int[3][ ]; //three rows array
array[0]=new int[1]; //first row has one element
array[1]=new int[2]; //2nd row has two
array[2]=new int[3]; //3rd row has three elements
2-dimensional array is declared as:
int[ , ] Array_name=new int[rows,columns]; //rectangular array
eg:
int[ , ] array=new int[3,3];
second is variable size arrays that are knows as jagged arrays.
The jagged array is two dimensional array having different length for each row.It can be declared as:
int[ ][ ] array_name=new [row][column];
eg:
int[ ][ ] array=new int[3][ ]; //three rows array
array[0]=new int[1]; //first row has one element
array[1]=new int[2]; //2nd row has two
array[2]=new int[3]; //3rd row has three elements
No comments:
Post a Comment