Use foreach statement to loop through jagged array : Jagged Arrays « Data Structure « C# / CSharp Tutorial






using System;

class MainClass
{
   static void Main()
   {
      int[][] arr1 = new int[2][];
      arr1[0] = new int[] { 1, 3 };
      arr1[1] = new int[] { 1, 1, 4 };

      foreach (int[] array in arr1)      
      {
         Console.WriteLine("Starting new array");
         foreach (int item in array)     
         {
            Console.WriteLine(" Item: {0}", item);
         }
      }
   }
}
Starting new array
 Item: 1
 Item: 3
Starting new array
 Item: 1
 Item: 1
 Item: 4








11.7.Jagged Arrays
11.7.1.Jagged With SubArrays
11.7.2.Use foreach statement to loop through jagged array
11.7.3.Demonstrate jagged arrays
11.7.4.Demonstrate Length with jagged arrays.
11.7.5.Multidimensional jagged arrays