Three dimensional arrays

The three dimensional arrays can be visualized as boxes within boxes. There is a big box, in which the other boxes are arranged in rows. In each row box, there can be other boxes, and finally, in the enclosed box will be values that are array elements.

Here is an example of 3-dim (3,2,2) array:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Collections;


namespace ConsoleApplication6
{
    
    class Program
    {
        static void Main(string[] args)
        {
            int[,,] threedim = {
                                 {
                                   {1, 2},
                                   {3, 4}
                                 },

                                 {
                                   {5, 6},
                                   {7, 8}
                                 },

                                 {
                                   {9,  10},
                                   {11, 12}
                                 }

                               };

            // Console.WriteLine("{0},{1},{2}", threedim.GetLength(0), threedim.GetLength(1), threedim.GetLength(2));

            Console.WriteLine(threedim[1,0,1]);

        }
    }
}

Consider above array as main box. In the box, there are three boxes in a row (from top to bottom). In each box there are 2 sub boxes, and in each sub box there are 2 elements.

Add a Comment

Your email address will not be published. Required fields are marked *