0
Is arr[][] allowed instead of arr[,] in C# ??
5 Antworten
+ 2
The syntax for declaration of a two dimensional array is arr[,] anything other than that is a syntax error.
arr[][] is used in C++ for the same purpose.
Something people should keep in mind is that in programming we have only one syntax for a specific job. There is no secondary syntax rule that you get to choose. This applies to all the programming languages.
At least that's what I have learned in years. I might be wrong.
+ 2
@Rey Silva That's syntax for declaring Jagged arrays not two dimensional arrays.
- 1
arr[,] -> Rectangular array (rows and columns are defined)
arr[][] -> Jagged array (columns can be different in different rows)
- 2
Yes it is (int [][] myArrey = new into[2][];) and then (myArrey[0] = new int[3];)
(myArrey[1] = new int[3])
now you have 2 rows and each row has 3 columns
- 2
typo it is supposed to be ( int ) not (into)