What is a jagged array?

 Posted by CGN007 on 5/30/2012 | Category: C# Interview questions | Views: 2546 | Points: 40

A jagged array in C# is an array of array.Its a special kind of two dimensional array in which the length of each row is different.

 type[ ] [ ] array-name = new type[size][ ];

Where array-name is the name of the jagged array, and size is the number of rows in that array.

 int[][] jaggedArray = new int[2][];

jaggedArray[0]=new int[3];
jaggedArray[2]=new int[4];

Here jagged array contains 2 rows,where the size of first row is 3 and the size of second row is 4.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response