belongs to collection: C# language array programs with an examples
Write C# Program to Demonstrate Jagged Arrays
I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.
using System; class Program { static void Main() { int[][] jagArray = new int[3][]; jagArray[0] = new int[2]; jagArray[0][0] = 12; jagArray[0][1] = 13; jagArray[1] = new int[1] { 12 }; jagArray[2] = new int[3] { 15, 16, 17 }; for (int i = 0; i < jagArray.Length; i++) { int[] innerArray = jagArray[i]; for (int a = 0; a < innerArray.Length; a++) { Console.WriteLine(innerArray[a] + " "); } } Console.Read(); } }
Result:
12
13
15
16
17
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.
Result:
12
13
12
15
16
17
need an explanation for this answer? contact us directly to get an explanation for this answer