Friday, 1 December 2017

C# Program to Demonstrate Jagged Arrays


Code:

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();
    }
}


Output:

11
12
11
14
15
16


More C# Programs:



















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...