Creating a room with doors in the for loop

Viewed 81

I'm new here. It's OK? My question is simple, I managed to generate walls with this simple for, but I just needed to generate a blank space as if it were a door. I'll leave my code below

enter image description here

class Program
    {
        static void Main(string[] args)
        {

            string[,] m = new string[10, 10];

            int row = m.GetLength(0);
            int colunm = m.GetLength(1);


            for (int i = 0; i < row; i++)
            {
                for (int k = 0; k < colunm; k++)
                {
                    m[i, k] = "-".ToString();

                }
            }


            //    Console.Write(m[1, 1]);

            for (int i = 0; i < row; i++)
            {

                for (int k = 0; k < colunm; k++)
                {
                    if (i == 0 || i == row - 1 || k == 0 || k == colunm - 1)
                        Console.Write(m[i,k] + " ");
                    else
                        Console.Write("  ");

                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }

    }
0 Answers
Related