12.2. Multi-dimensional arrays: rectangular arrays

Rectangular arrays are, as the name implies, arrays which look like a table. A 2D rectangular array can be represented as a plane rectangle, and a 3D rectangular array can be represented as a cuboid. [4] Whatever the case, the idea is the same – in rectangular arrays, every row has the same number of columns. Jagged arrays differ from this as you will see later.

[4] Some people have great difficulty understanding 4D arrays and above because it is difficult to picture a 4D rectangular array as represented by a simple object (a 4D shape?) in our 3D world.

The syntax for rectangular arrays is different from Java. Study the statements below and note the syntactical differences.

  • Declaring a 2D rectangular ...

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.