public static void Main (string[] args)
   {

      int row;
      int column;
      int[,] game;
      game = new int[3, 3] { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };

Console.WriteLine("Player 1's turn.");
      Console.Write("Enter row [1, 2 or 3]: ");
      row = Convert.ToInt32(Console.ReadLine());
      Console.Write("Enter column [1, 2 or 3]: ");
      column = Convert.ToInt32(Console.ReadLine());
      if (game[row,column] == 1 || game[row,column] == 2)
      {
         Console.WriteLine("Sorry that square is unavailable.  Please choose another one.");
         Console.Write("Enter row [1, 2 or 3]: ");
         row = Convert.ToInt32(Console.ReadLine());
         Console.Write("Enter column [1, 2 or 3]: ");
         column = Convert.ToInt32(Console.ReadLine());
      }
      else
      {
         game[--row, --column] = 1;
      }

that's the code, and I keep getting the error: Unhandled exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.

There is something wrong it says with the IF statement. Any ideas?

The error means that either row or column is not 0, 1 or 2.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.