这两种声明数组的方式有什么区别? [英] What is the difference between these two ways of declaring an array?
本文介绍了这两种声明数组的方式有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
两者之间有什么区别
int [][] myArray;
和
int [,] myOtherArray;
推荐答案
第一个是锯齿状数组:一个数组,其中数组中的每个项目都是另一个数组
The first is a jagged array: an array where each item in the array is another array
int[][] jaggedArray = new int[3][];
jaggedArray[0] = new int[5];
jaggedArray[1] = new int[4];
jaggedArray[2] = new int[2];
第二个是多维数组,又称矩阵.
The second is a multidimensional array, aka a matrix.
int[,] array = new int[4, 2]; // create a 4 by 2 matrix
这篇关于这两种声明数组的方式有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文