Home » C# Multidimensional Array

C# Multidimensional Array

by Online Tutorials Library

C# Multidimensional Arrays

The multidimensional array is also known as rectangular arrays in C#. It can be two dimensional or three dimensional. The data is stored in tabular form (row * column) which is also known as matrix.

To create multidimensional array, we need to use comma inside the square brackets. For example:

C# Multidimensional Array Example

Let’s see a simple example of multidimensional array in C# which declares, initializes and traverse two dimensional array.

Output:

0 10 0 0 0 20 30 0 0 

C# Multidimensional Array Example: Declaration and initialization at same time

There are 3 ways to initialize multidimensional array in C# while declaration.

We can omit the array size.

We can omit the new operator also.

Let’s see a simple example of multidimensional array which initializes array at the time of declaration.

Output:

1 2 3 4 5 6 7 8 9 
Next TopicC# Jagged Arrays

You may also like