Get the width and height of a three-dimensional array


Let’s say our three-dimensional array is −

int[,,] arr = new int[3,4,5];

To get the height and width i.e. the rows and columns.

Array.GetLength(0) – for rows
Array.GetLength(1) – for columns

Example

 Live Demo

using System;
class Program {
   static void Main() {
      int[,,] arr = new int[3,4,5];
      Console.WriteLine(arr.GetLength(0));
      Console.WriteLine(arr.GetLength(1));
      Console.WriteLine(arr.GetLength(2));
   }
}

Output

3
4
5

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 23-Jun-2020

188 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements