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