By 22/07/2015 1 Comments

Multidimensional Jagged Array In C#

  • Multidimensional Jagged Array In C# can be declared.
  • It is a useful in some cases.
  • It can be declared as 2 dimensional 2D, 3 dimensional 3D or even more dimensions.

General Syntax:

type [ ] [ , ] array-name = new type[size] [ , ];

[ ] [ , ] A comma (,) inside square bracket indicates that it is a Multidimensional jagged array.
[size] [ , ] Size bracket indicates the size of an array that means how many rows or inner arrays can be hold by jagged array and a comma (,) indicates that it is a 2 Dimensional 2D Jagged Array.


using System;
namespace csharpBasic
    class Program
        static void Main(string[] args)
   // Multidimensional 2D jagged Array declaration with size 1.
            string[][,] programingLanguages = new string[1][,];

   // Statement assigns new 2D array into jagged array’s index which is 0.
            programingLanguages[0] = new string[2, 2];

   // Statements assign different elements or values in each 2D Jagged Array’s indices.
            programingLanguages[0][0, 0] = "C#";
            programingLanguages[0][0, 1] = "";
            programingLanguages[0][1, 0] = "Javascript";
            programingLanguages[0][1, 1] = "Css3";

    // Outer loop iterates each jagged array’s index.
            for (int jaggedIndex = 0; jaggedIndex < 1; jaggedIndex++)

    // Inner loop iterates each 2D array’s rows index.
                for (int rows = 0; rows < 2; rows++)

    // Most inner loop iterates each 2D array’s columns index.
                    for (int cols = 0; cols < 2; cols++)

                        Console.WriteLine(programingLanguages[jaggedIndex][rows, cols]);

        The Output will be:

← Previous Tutorial

Posted in: C# Basics, C#.NET

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .