View Single Post
  #2 (permalink)  
Old 07-19-2007, 06:07 AM
Gopisoft Gopisoft is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Posts: 117
Gopisoft is on a distinguished road
Default Re: Jagged Arrarys

A Jagged array is an array whose elements are also an array.the Elements of Jagged array can be of different sizes.It is Called as Array of Arrays.It is Called jagged because of its row in different SIze.

Jagged array declaration in C#:

Code:
 

int [] [] myJaggedArray = new int [3][];

Declaration of inner arrays: 
 
 myJaggedArray[0] = new int[5] ;   // First inner array will be of length 5.
 myJaggedArray[1] = new int[4] ;  // Second inner array will be of length 4.
 myJaggedArray[2] = new int[3] ;   // Third inner array will be of length 3.

Now to access third element of second row we write:

  int value = myJaggedArray[1][2];
Note: Jagged arrays are not rectangular arrays Like Multi-Diemnsional Arrays.
Reply With Quote