0

I need to make 2d array of arrays.

int[,][] array = new int[n,m][]; 
  for (int i=0; i< m; i++)
    {
      for (int j=0; j< n; j++)
        {
          int r = ran.Next(1, 7);
          int[] arraybuf = new int[r]; 
          for (int z = 0; z < r; z++)
            {
              arraybuf[z] = 1;
            }
          array[i, j] = arraybuf;
          Console.WriteLine(array[i, j]);                                
        }
            Console.WriteLine();
   }

When i'm doing this, console shows

System.Int32[]

in every place where array must be.

1
  • 1
    What are you expecting Console.WriteLine(array[i, j]); to print? You've given it an array of int, and there's no special overload of WriteLine() to print those. Commented Feb 18, 2016 at 22:03

1 Answer 1

3

Because it is an array. You have an 2D array of arrays of type int.

If you want to display the contents of the array in a specific cell you could do:

   Console.WriteLine(string.Join(", ", array[i, j]));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.