12.1. One-dimensional arrays
The syntax for array declaration is the same in C# as in Java, except for one difference – when declaring an array, Java permits putting the square brackets either in front of or behind the array's type. C# only allows the former – Putting the square brackets after an array identifier will cause a compilation error. [3]
[3] C/C++ mandates that the square brackets be behind the array type (as in int array[];).
Both the following declarations are okay in Java:
int MyArray[];
int []MyArray;
However, only int []MyArray; is legal in C#.
Other than that, the syntax for array declaration, instantiation, and initialization are identical in C# and Java as far as 1D arrays are concerned. Examples are shown below as a refresher ...
Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.