如何在 C# 中检查二维(或更多)维数组的大小?

发布于 2024-10-07 13:37:19 字数 148 浏览 0 评论 0原文

我有:

double[,] table = new double[3,4];

如何检查该表的两种尺寸? table.Length 给我 12 这是表中元素的总数。

I have:

double[,] table = new double[3,4];

How to check both sizes of that table? table.Length gives me 12 which is total number of elements in table.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凉风有信 2024-10-14 13:37:19

使用GetLength 方法。

因此,table.GetLength(0) 将返回 3,table.GetLength(1) 将返回 4。

GetLength 的参数是零您想知道其长度的数组的基维。

Use the GetLength method.

So table.GetLength(0) will return 3 and table.GetLength(1) will return 4.

The parameter for GetLength is the zero-based dimension of the array you want to know the length of.

甜点 2024-10-14 13:37:19

Table.GetLength(0); 为您提供 3

Table.GetLength(1); 为您提供 4

希望这会有所帮助。

Table.GetLength(0); gives you 3

Table.GetLength(1); gives you 4

Hope this helps.

我只土不豪 2024-10-14 13:37:19

获取长度?

参考

GetLength?

ref

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文