c# changing specific index location within a 2 dim string array

85 Views Asked by At

`

string[,] Board = new string[10, 11];
         int i;
            int x;

            Console.WriteLine("  ¦ A B C D E F G H I J");
            Console.WriteLine("--+--------------------");
            for (i = 0; i <= 9; i++)
            {
                if(Row != 9)
                Console.Write((i + 1).ToString() + " ¦ ");
                else
                    Console.Write((i + 1).ToString() + "¦ ");
                for (j = 0; j <= 9; j++)
                {
                    Console.Write(Board[j, i] + "# ");
                }
                Console.WriteLine();
            }

            Console.WriteLine("\n");
    }

I would like to change the "# " at row 4 and column 5 with an "X ".

I tried the code: array[4, 5] = "X ";

but when I run the program it does not reassign the "# " at row 4 column 5 to "X "

I'm not sure what I doing wrong with the line: array[4, 5] = "X ";

I tried the code: Board.SetValue("X ", int.Parse((Board[4, 5])));

but even that will not change the # in that one location to an "X" while leaving the rest as #

0

There are 0 best solutions below