Jagged array in C#

Posted by CGN007 under C# category on | Points: 40 | Views : 1589
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.

Comments or Responses

Login to post response