What is the difference between array [] [] and array [,]?

Can someone explain the difference between the two ads?

  • double dArray[][];
  • double dArray[,];
+4
source share
4 answers
 double dArray[][]; 

is an array of arrays, and

 double dArray[,]; 

is a two-dimensional array.

easy enough to find them.

MSDN Link Link

+7
source

The latter syntax is simple; it declares a multi-dimensional array of twins. Imagine that the array is 3x2, then there will be 6 pairs in the array.

1st syntax declares a jagged array. The second syntax is rectangular or square, but this syntax is optional. You can have three rows followed by 3 columns, then 2 columns, then 1 column, i.e. Its notched.

 2nd: 1-1, 1-2, 1-3 2-1, 2-2, 2-3 1st: 1-1, 1-2, 1-3 2-1, 2-2, 3-1, 
+3
source

The first is an array of double arrays, each individual element in dArray can contain a different number of doublings depending on the length of the array.

 double[][] dArray = new double[3][]; dArray[0] = new double[3]; dArray[1] = new double[2]; dArray[2] = new double[4]; Index 0 1 2 ----- ----- ----- L 1 | | | | | | e ----- ----- ----- n 2 | | | | | | g ----- ----- ----- t 3 | | | | h ----- ----- 4 | | ----- 

The second is called a multidimensional array and can be considered as a matrix, as rows and columns.

 double[,] dArray = new dArray[3, 3]; Column 0 1 2 ------------- 0 | | | | R ------------- o 1 | | | | w ------------- 2 | | | | ------------- 
+3
source

See the official documentation (click on the C # tab).

+1
source

Source: https://habr.com/ru/post/1341740/


All Articles