How to get three dimensional array length in C#

1 Answer

0 votes
using System;
 
class Program
{
    static void Main() {
         int[,,] array3d = new int[,,] { { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } },
                                         { { 10, 20, 30, 40 }, { 50, 60, 70, 80 } },
                                         { { 9, 10, 11, 12 }, { 13, 14, 15, 16 } } };
 
        Console.WriteLine(array3d.GetLength(0));
        Console.WriteLine(array3d.GetLength(1));
        Console.WriteLine(array3d.GetLength(2));
    }
}
 
 
 
 
/*
run:
 
3
2
4
 
*/

 



answered Nov 25, 2020 by avibootz

Related questions

1 answer 128 views
1 answer 111 views
1 answer 167 views
1 answer 189 views
1 answer 121 views
...