Create Jagged Array

Madhu.b.rokkam
Posted by Madhu.b.rokkam under C# category on | Points: 40 | Views : 5492
What are jagged arrays ???

Arrays of arrays is called as Jagged arrays.
Lets see an example:

int[][] jArray = new int[3][];
jArray[0] = new int[] { 2, 4, 6 };
jArray[1] = new int[] { 1,3,5,7,9 };
jArray[2] = new int[] { 4,9,16,25 };

int val = jArray[0][1]; //4
int val1 = jArray[1][2]; //5

Comments or Responses

Posted by: Karthikanbarasan on: 2/24/2011 Level:Silver | Status: [Member] [Moderator] [Microsoft_MVP] [MVP] | Points: 10
Can you explain a bit on this code... its confusing!!!
Posted by: Madhu.b.rokkam on: 2/27/2011 Level:Bronze | Status: [Member] [MVP] | Points: 10
Jagged Array is the collection of arrays where we have multiple rows and columns and they may also vary in length also. As shown in the example.

Login to post response