0

Is arr[][] allowed instead of arr[,] in C# ??

6th Aug 2016, 9:14 AM
Pro D
5 Respuestas
+ 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.
6th Aug 2016, 10:55 AM
Alireza M
Alireza M - avatar
+ 2
@Rey Silva That's syntax for declaring Jagged arrays not two dimensional arrays.
6th Aug 2016, 6:58 PM
Alireza M
Alireza M - avatar
- 1
arr[,] -> Rectangular array (rows and columns are defined) arr[][] -> Jagged array (columns can be different in different rows)
7th Aug 2016, 3:10 PM
Fawad Ghori
Fawad Ghori - avatar
- 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
6th Aug 2016, 6:43 PM
Rey Silva
Rey Silva - avatar
- 2
typo it is supposed to be ( int ) not (into)
6th Aug 2016, 6:46 PM
Rey Silva
Rey Silva - avatar