也建议你搜索什么是"交错数组"。 [解决办法] 是交错数组。 [解决办法] 没有这种写法,你要创造,当然不对 [解决办法] 首先C#中二维数组的定义是通过int[,] b = new int[count,count]实现,定义了一个count行count列的数组。 int[][] a,这种形式是一种类似不确定列的数组结构。 int [][] a = new int[10][];//定义一个10容纳十个元素的对象啊,每个元素是int[],其中元素个数不确定。 a[0][] = new int[10];//a的第一个位置是可容纳10个int的一维数组 a[1][] = new int[50];//a的第一个位置是可容纳50个int的一维数组 a[2][] = new int [5];//a的第一个位置是可容纳5个int的一维数组 ... [解决办法] 交错数组 [解决办法] int[][] a = new int[count][count];// 报错 => int[][] a = new int[count][]; for (int i = 0; i < a.Length; i++) { a[i] = new int[count]; } [解决办法]
[解决办法] 围观一下 发现我当初看数组的时候也有过类似的问题想问 不过现在明白了 [解决办法] int[][] a = new int[count][];//交错数组,有count个数组,每个数组的元素个数不固定,不知道每行有几列 int[,] b = new int[count,count];//二维数组,固定有几行几列了。 [解决办法] 交错数组,我也头回听说,老长见识了! [解决办法] int[][] a = new int[count][];// 交错数组 int[,] b = new int[count,count];// 二维数组