Jagged Array

Learn how a multi-dimensional array can have different numbers of elements in rows.

We'll cover the following

What is a jagged array?

A jagged array is when arrays of various sizes are put inside another array.

Example: Declare a jagged array

string[][] jaggedEx = new string[3][];

Example: Assign arrays to an array

jaggedEx[0] = new string[2]; // 2 element array 
jaggedEx[1] = new string[5]; // 5 element array 
jaggedEx[2] = new string[8]; // 8 element array

Below is a visual representation of the jagged array created in the previous examples. The jagged array contains three arrays of different sizes.

Get hands-on with 1200+ tech skills courses.