สมมติว่าอาร์เรย์สามมิติของเราคือ −
int[,,] arr = new int[3,4,5];
เพื่อให้ได้ความสูงและความกว้าง เช่น แถวและคอลัมน์
Array.GetLength(0) – for rows Array.GetLength(1) – for columns
ตัวอย่าง
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));
}
} ผลลัพธ์
3 4 5