A jagged array is a special type of array. It stores arrays as it’s elements. The length of each row of a jagged array can differ. A jagged array is also called an Array of Arrays.

Example – Jagged array with single dimensional array as elements

using System;   //Adding namespaces
namespace LearnCSharp //Namespace of the class
{
class Program //The class
{
static void Main(string[] args) //Main method
{
int[][] jaggedArray = new int[3][];

jaggedArray[0] = new int[] { 1, 2, 3, 4 };
jaggedArray[1] = new int[] { 5, 6, 7 };
jaggedArray[2] = new int[] { 8, 9 };

//Displaying values
Console.WriteLine(jaggedArray[0][0]);
Console.WriteLine(jaggedArray[1][0]);
Console.ReadKey();
}
}
}

Output

1
5

Example – Jagged array with a multi-dimensional array as elements

using System;   //Adding namespaces
namespace LearnCSharp //Namespace of the class
{
class Program //The class
{
static void Main(string[] args) //Main method
{
int[][,] jaggedArray = new int[3][,]
{
new int[,] { {0, 1}, {2, 3} },
new int[,] { {4, 5}, {6, 7}, {8, 9} },
new int[,] { {10, 11}, {12, 13}, {14, 15} }
};
//Displaying values
Console.WriteLine(jaggedArray[0][0, 0]);
Console.WriteLine(jaggedArray[1][0, 0]);
Console.ReadKey();
}
}
}

Output

0
4