What is a jagged array?

A jagged array is an array of arrays.

string[][] arrays = new string[5][];

That’s a collection of five different string arrays, each could be a different length (they could also be the same length, but the point is there is no guarantee that they are).

arrays[0] = new string[5];
arrays[1] = new string[100];
...

This is different from a 2D array where it is rectangular, meaning each row has the same number of columns.

string[,] array = new string[3,5];

Leave a Comment