多维数组符号之差(对象[] []和对象[,]) [英] Difference between Multidimensional Array notations (object[][] and object[,])

查看:126
本文介绍了多维数组符号之差(对象[] []和对象[,])的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是什么,两种方法来定义在C#多维数组之间的区别。

I am wondering what is the difference between the two ways to define a Multidimensional Array in C#.

您可以使用对象[] [ ] 对象[,] 与多维数组工作。

You can use object[][] and object[,] to work with multidimensional array.

是否有功能区别在哪里?

Are there functional differences?

推荐答案

对象[] [] 是一个符号阵列阵列。第二个对象[,] 是一个二维阵列。

The object[][] is a notation for array of arrays. The second one object[,] is a two dimensional array.

的主要区别在于,而在第一次。含有不同长度的内部的阵列,第二个必须是长方形(如4X7)

The main difference is while the first one can contain different length "inner" arrays, the second one must be rectangular (e.g. 4x7).

例如:

int[][] a = new int[] { new int[]{ 1, 2 }, new int[]{ 3, 4, 5, 6, 7 }};
int[,] b = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };

这是一个官方的教程。

这篇关于多维数组符号之差(对象[] []和对象[,])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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