多个维度的索引 [英] indices in more than one dimensions

查看:100
本文介绍了多个维度的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好专家,

在C#中,可以用不同的方式声明二维整数数组:

Hello Experts,

in C# one can declare a two-dimensional array of integral numbers in different ways:

int[,] a;
int[][] b;

两者之间有什么区别?
在什么情况下,我应该优先选择另一个?

预先感谢,


luker

What is the difference between the two?
In what cases am I to prefer one over the other?

Thanks in advance,


luker

推荐答案



第一个
Hi,

The first one,
int[,] a;

被称为矩形数组.这是声明二维数组或多维数组的常用方法.

第二个

is called Rectangular array. It is the common way for declaring two-dimentional array or multi-dimentional array.

The second one,

int[][] b; 

称为锯齿状数组.简单地说,锯齿状数组就是数组的数组.

这里的行数是固定的,但是我们可以更改列数.

例如,第一行可以包含5列(例如...),第二行可以更改为具有7列(例如...)...这就是锯齿状数组的用途.

问候,
Suresh

is called Jagged array. To explain simply, Jagged array is array of array.

Here number of rows is fixed but we can changed the number of columns.

For example, 1st row can contain 5 columns (say...), 2nd row can be changed to have 7 columns (say...)... This is the purpose of Jagged array.

Regards,
Suresh


这篇关于多个维度的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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