15,299,850 members
1.00/5 (1 vote)
See more:
Create a function that can print a three dimension integer array Array3D. Dimensions information is also passed as integer array Info where Info[0], Info[1] and Info[2] represent the number of elements in first, second and third dimensions

What I have tried:

C#
```int[,,] Array3D = new int[1, 2, 3] { { { 1, 2, 3 },
{ 3, 4, 5 }} };
for (int i = 0; i < Array3D.GetLength(0); i++)
{
for (int j = 0; j < Array3D.GetLength(1); j++)
{
for (int k = 0; k < Array3D.GetLength(2); k++)
{
Console.Write("{0} ", Array3D[i, j, k]);
}

}```
Posted
Updated 11-Jan-21 13:48pm
v2
Richard MacCutchan 11-Jan-21 11:45am

What you have tried does not follow the instructions, which clearly state: "Dimensions information is also passed as integer array Info where Info[0], Info[1] and Info[2] represent the number of elements in first, second and third dimensions".

So the first thing to do is to define a method that will accept the appropriate parameters.

## Solution 1

Quote:
Create a function that can print a three dimension integer array Array3D. Dimensions information is also passed as integer array Info where Info[0], Info[1] and Info[2] represent the number of elements in first, second and third dimensions

It doesn't look like your code does that.
Quote:
Create a function that can print a three dimension integer array Array3D. Dimensions information is also passed as integer array Info where Info[0], Info[1] and Info[2] represent the number of elements in first, second and third dimensions

Your code doesn't do that either.

So your function - when you write it - needs to accept two parameters: teh array, and a second array describing the first.

You have to read the question, and think about what it wants - rather than just leaping into code, or - more likely - copy'n'paste code that does something similar (you hope) from the internet. You won't learn anything that way!

## Solution 2

In C# a function is usually called a method, see examples here: C# Methods[^]