programming-examples/c-sharp/Arrays/C# Program to Demonstrate Jagged Arrays.cs

33 lines
668 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Demonstrate Jagged Arrays
*/
using System;
class Program
{
static void Main()
{
int[][] jag = new int[3][];
jag[0] = new int[2];
jag[0][0] = 11;
jag[0][1] = 12;
jag[1] = new int[1] {11};
jag[2] = new int[3] { 14,15, 16 };
for (int i = 0; i < jag.Length; i++)
{
int[] innerArray = jag[i];
for (int a = 0; a < innerArray.Length; a++)
{
Console.WriteLine(innerArray[a] + " ");
}
}
Console.Read();
}
}
/*
11
12
11
14
15
16