Jagged Array

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. namespace pr   
  6. {  
  7.     class Program   
  8.     {  
  9.         static void Main(string[] args)   
  10.         {  
  11.             int[][] A = new int[3][];  
  12.             A[0] = new int[5]   
  13.             {  
  14.                 2,  
  15.                 5,  
  16.                 7,  
  17.                 4,  
  18.                 9  
  19.             };  
  20.             A[1] = new int[4]   
  21.             {  
  22.                 3,  
  23.                 6,  
  24.                 7,  
  25.                 8  
  26.             };  
  27.             A[2] = new int[6] {  
  28.                 5,  
  29.                 78,  
  30.                 54,  
  31.                 65,  
  32.                 34,  
  33.                 90  
  34.             };  
  35.             Console.WriteLine("elements of jagged array are :-");  
  36.             for (int R = 0; R < A.Length; R++) {  
  37.                 for (int C = 0; C < A[R].Length; C++) {  
  38.                     Console.Write(A[R][C] + " ");  
  39.                 }  
  40.                 Console.WriteLine();  
  41.             }  
  42.             Console.Read();  
  43.         }  
  44.     }  
  45. }