'I want to create a 30x30 matrix array of 1s and 0s

I want to create a 30x30 matrix array of 1s and 0s. This will be a maze with 1's being the path and 0's being a wall. but this labyrinth should contain a way guarantee. How can I do that? What is its c# code?

enter image description here



Solution 1:[1]

int[,] gameSpace = new int[30,30];
        public void Create()
        {
            // {30 x 30} maze creating.
            Random numGen = new Random();
            for (int i = 0; i < 30; i++)
            {
                Console.Write("{");
                for (int j = 0; j < 30; j++)
                {
                    oyunAlani[i, j] = numGen.Next(0, 2);
                    Console.Write(gameSpace[i, j] + ",");
                }
                Console.Write("}\n");
            }
        }//But it doesn't contain a path.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1