Jagged Array
using System;
//Jagged arrays are often called array of arrays. An element of a jagged array itself is an array.
class JaggedArray
{
static void Main(string[] args)
{
int[][] numArray = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6, 7, 8 } }; // Here numArray is having 2 integer arrays.
// Iterating the jagged array
Console.WriteLine("Contents of jagged array: ");
foreach (int[] i in numArray) // Each element in numArray is an integer array i
{
foreach (int j in i) // Each element in integer array i is an integer j
{
Console.Write(j + ",");
}
}
Console.ReadLine();
}
}
Output:
Contents of jagged array:
1,2,3,4,5,6,7,8,