As you can see there are 7 'figures' in my 3d array. How can I randomly choose an 2d array from the 3d array? If I execute my code now, it will take a random number inside the 2d array but it must give the whole array as the output.
// Online C# Editor for free
// Write, Edit and Run your C# code using C# Online Compiler
using System;
public class HelloWorld
{
public static void Main(string[] args)
{
Random rnd = new Random();
int[,,] pieces ={ { {0, 1, 0, 0},
{0, 1, 0, 0},
{0, 1, 0, 0},
{0, 1, 0, 0} },
{ {0, 1, 0, 0},
{0, 1, 0, 0},
{0, 1, 1, 0},
{0, 0, 0, 0} },
{ {0, 0, 1, 0},
{0, 0, 1, 0},
{0, 1, 1, 0},
{0, 0, 0, 0} },
{ {0, 0, 0, 0},
{1, 1, 1, 0},
{0, 1, 0, 0},
{0, 0, 0, 0} },
{ {0, 0, 0, 0},
{0, 1, 1, 0},
{0, 1, 1, 0},
{0, 0, 0, 0} },
{ {0, 0, 0, 0},
{0, 0, 1, 1},
{0, 1, 1, 0},
{0, 0, 0, 0} },
{ {0, 0, 0, 0},
{1, 1, 0, 0},
{0, 1, 1, 0},
{0, 0, 0, 0} } };
//int[,] returnPiece = pieces[rnd.Next(1, 8)];
int a = pieces[rnd.Next(pieces.GetLength(0)), rnd.Next(pieces.GetLength(1)), rnd.Next(pieces.GetLength(2))];
Console.WriteLine(a);
}
}