Multi dimensional arrays are defined as three dimensional arrays. The elements which are more than two dimensional arrays are called multi dimensional arrays.
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main() { string[, ,] vehicles3D = new string[2, 2, 2] { { { "car", "auto" }, { "bus", "plane" } }, { { "train", "scooty" }, { "bike", "cycle" } } }; // Two dimensional array with fixed size.. Console.WriteLine(vehicles3D[0, 0, 0]); Console.WriteLine(vehicles3D[1, 1, 1]); Console.WriteLine(vehicles3D[1, 0, 1]); Console.WriteLine(vehicles3D[0, 1, 1]); } }
In the above code snippet we have defined three dimensional arrays using string values as vehicles, we are having two indexes and two elements and two subelements, in the first line we declared (0,0,0,), it is defined as 0th index and 0th element and 0th subelement and prints the value as car, In the second line we are having (1,1,1), it is defined as 1st index and 1st element and 1st subelement and prints the value as cycle. In the third line we are having (1,0,1), it is defined as 1 st index and 0 th element and 1 sub element and it prints the value as scooty, in the fourth line we have declared as (0,1,1) it is declared as oth index and 1st element and 1st sub element and it prints the value as plane.
output:
Views: 4403 | Post Order: 12