static char[,] grid = new char[6, 7];
for (int row = 0; row < grid.GetLength(0); row++)
for (int column = 0; column < grid.GetLength(1); column++)
Console.WriteLine("Game over!");
Console.WriteLine("\n\n[Player X] Drop an X token into column #: ");
string columnString = Console.ReadLine();
columnChoice = Convert.ToInt16(columnString);
Console.WriteLine("That's not a number!");
catch (OverflowException)
Console.WriteLine("That number is too large!");
bool win = UpdateGrid(columnChoice, x);
Console.WriteLine("\n\n[Player O] Drop an O token into column #: ");
string columnString = Console.ReadLine();
columnChoice = Convert.ToInt16(columnString);
Console.WriteLine("That's not a number!");
catch (OverflowException)
Console.WriteLine("That number is too large!");
bool win = UpdateGrid(columnChoice, o);
static bool UpdateGrid(short column, char x_or_o)
if (grid[0, column] == '.')
if (grid[1, column] == '.')
if (grid[2, column] == '.')
if (grid[3, column] == '.')
if (grid[4, column] == '.')
if (grid[5, column] == '.')
grid[5, column] = x_or_o;
grid[4, column] = x_or_o;
grid[3, column] = x_or_o;
grid[2, column] = x_or_o;
grid[1, column] = x_or_o;
grid[0, column] = x_or_o;
if (grid[row+1, column] == x_or_o)
if (grid[row+2, column] == x_or_o)
if (grid[row+3, column] == x_or_o)
catch (IndexOutOfRangeException){}
if (grid[row+1, column+1] == x_or_o)
if (grid[row+2, column+2] == x_or_o)
if (grid[row+3, column+3] == x_or_o)
catch (IndexOutOfRangeException) {}
if (grid[row+1, column-1] == x_or_o)
if (grid[row+2, column-2] == x_or_o)
if (grid[row+3, column-3] == x_or_o)
catch (IndexOutOfRangeException) {}
if (grid[row, column+1] == x_or_o)
if (grid[row, column+2] == x_or_o)
if (grid[row, column+3] == x_or_o)
catch (IndexOutOfRangeException) {}
if (grid[row, column-1] == x_or_o)
if (grid[row, column-2] == x_or_o)
if (grid[row, column-3] == x_or_o)
catch (IndexOutOfRangeException) {}
if (grid[row-1, column+1] == x_or_o)
if (grid[row-2, column+2] == x_or_o)
if (grid[row-3, column+3] == x_or_o)
catch (IndexOutOfRangeException) {}
if (grid[row-1, column-1] == x_or_o)
if (grid[row-2, column-2] == x_or_o)
if (grid[row-3, column-3] == x_or_o)
catch (IndexOutOfRangeException) {}
static void DisplayGrid()
for (int i = 0; i < grid.GetLength(1); i++)
Console.Write(i + 1 + " ");
for (int row = 0; row < grid.GetLength(0); row++)
for (int column = 0; column < grid.GetLength(1); column++)
Console.Write(grid[row, column] + " ");