Jagged Array in C# is typical 1 dimensional array ,Array always needs length to be initialized. But how come references of arrays which do not have length initialized, are holding inside a jagged array ? How memory locations are allocated for those referenced arrays ?
int[][] arr = new int[2][];
for (int i = 1; i <= 2; i++)
{
arr[i-1] = new int[i * 5];
for (int j = 0; j < i*5; j++)
{
arr[i-1][j] = j;
}
}
for (int i = 0; i < arr.Length; i++)
{
Console.Write("Element({0}): ", i);
for (int j = 0; j < arr[i].Length; j++)
{
Console.Write("{0}{1}", arr[i][j], j == (arr[i].Length - 1) ? "" : " ");
}
Console.WriteLine();
}
Console.WriteLine(arr.Length);
Console.WriteLine(arr.Rank);