双[,]类型,如何让行#? [英] double[,] type, how to get the # of rows?

查看:104
本文介绍了双[,]类型,如何让行#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎得到一个奇怪的值。

I seem to be getting an odd value.

我如何得到我的阵列中的行数:

How do I get the number of rows in my array:

double[,] lookup = { {1,2,3}, {4,5,6} };

输出应为2。

推荐答案

查找有两个维度,这就是你如何阅读

lookup has two dimensions, this is how you read them

double[,] lookup = { {1,2,3}, {4,5,6} };

int rows = lookup.GetLength(0); // 2
int cols = lookup.GetLength(1); // 3    
int cells = lookup.Length; // 2*3 = 6

COLS 的概念只是传统,你也可以同样拨打第一维列。

The rows and cols concept is just tradition, you could just as well call the first dimension the columns.

另请参阅<一个href=\"http://stackoverflow.com/questions/586972/how-to-get-multidimensional-length-of-one-axis/587017#587017\">this问题

这篇关于双[,]类型,如何让行#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆