C# 中陣列的三維尺寸
要獲取 C# 中 3D 陣列的大小,請將其 `GetLength()` 方法與維度索引一起作為引數使用。
GetLength(dimensionIndex)
要獲取大小。
arr.GetLength(0) arr.GetLength(1) arr.GetLength(2)
示例
using System;
class Program {
static void Main() {
int[,,] arr = new int[3,4,5];
// length of a dimension
Console.WriteLine(arr.GetLength(0));
Console.WriteLine(arr.GetLength(1));
Console.WriteLine(arr.GetLength(2));
// length
Console.WriteLine(arr.Length);
}
}輸出
3 4 5 60
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP