How to get the length of a multidimensional array in C#

2 Answers

0 votes
using System;

class Program
{
    static void Main() {
        int[,,] arr = new int [2, 3, 7];

        Console.WriteLine(arr.GetLength(0));
        Console.WriteLine(arr.GetLength(1));
        Console.WriteLine(arr.GetLength(2));
    }
}




/*
run:

2
3
7

*/

 



answered Jun 23, 2021 by avibootz
0 votes
using System;

class Program
{
    static void Main() {
        int[,] arr = new int [4, 9];

        Console.WriteLine(arr.GetLength(0));
        Console.WriteLine(arr.GetLength(1));
    }
}




/*
run:

4
9

*/

 



answered Jun 23, 2021 by avibootz

Related questions

1 answer 150 views
1 answer 141 views
1 answer 120 views
1 answer 90 views
90 views asked Nov 25, 2020 by avibootz
...