title: Displaying Xs and Os for C# tic tac toe
body: <p>I am trying to write a simple tic tac toe program for class. I know there are other posts on the site responding to similar course work but I can't find the help I need. I have a 2d array set up for my grid. I have 9 labels to hold the random generated 0 or 1 to represent the X(1) or O(0). My issue is that I am unsure of how to display an X or an O instead of the number. Also, I have a several lines set to check if X or O won, however, I don't know how to show if it is a tie. I am not looking for a direct answer but guidance on how to accomplish this. As of right now, my form will display random 1s and 0s and if the conditions are met will state if X or O won, but it does this even if X or O did not win. There is no human element to this game other than to click the button that calls the function to generate the numbers and update the form. My code is as follows:</p>
  
  <pre><code>    using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace TicTacToe
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          private void playAgain_Click(object sender, EventArgs e)
          {
              Random rand = new Random();
              const int rows = 3;
              const int columns = 3;
              int[,] board = new int[rows, columns];
  
              for (int row = 0; row &lt; rows; row++)
              {
                  for (int col = 0; col &lt; columns; col++)
                  {
                      board[row, col] = rand.Next(2);
                  }
              }
  
              square1.Text = board[0, 0].ToString();
              square2.Text = board[0, 1].ToString();
              square3.Text = board[0, 2].ToString();
              square4.Text = board[1, 0].ToString();
              square5.Text = board[1, 1].ToString();
              square6.Text = board[1, 2].ToString();
              square7.Text = board[2, 0].ToString();
              square8.Text = board[2, 1].ToString();
              square9.Text = board[2, 2].ToString();
  
              //O win check
              if (board[0,0] == 0 &amp;&amp; (board[0,0] == board[0,1]) &amp;&amp; (board[0,1] == board[0,2]))
              {
                  winnerBox.Text = "O wins!";
              }
              else if (board[1, 0] == 0 &amp;&amp; (board[1, 0] == board[1, 1]) &amp;&amp; (board[1, 1] == board[1, 2]))
              {
                  winnerBox.Text = "O wins!";
              }
              else if (board[2, 0] == 0 &amp;&amp; (board[2, 0] == board[2, 1]) &amp;&amp; (board[2, 1] == board[2, 2]))
              {
                  winnerBox.Text = "O wins!";
              }
              else if (board[0, 0] == 0 &amp;&amp; (board[0, 0] == board[1, 0]) &amp;&amp; (board[1, 0] == board[2, 0]))
              {
                  winnerBox.Text = "O wins!";
              }
              else if (board[0, 1] == 0 &amp;&amp; (board[0, 1] == board[1, 1]) &amp;&amp; (board[1, 1] == board[2, 1]))
              {
                  winnerBox.Text = "O wins!";
              }
              else if (board[0, 2] == 0 &amp;&amp; (board[0, 2] == board[1, 2]) &amp;&amp; (board[1, 2] == board[2, 2]))
              {
                  winnerBox.Text = "O wins!";
              }
              else if (board[0, 0] == 0 &amp;&amp; (board[0, 0] == board[1, 1]) &amp;&amp; (board[1, 1] == board[2, 2]))
              {
                  winnerBox.Text = "O wins!";
              }
              else if (board[0, 2] == 0 &amp;&amp; (board[0, 2] == board[1, 1]) &amp;&amp; (board[0, 1] == board[2, 0]))
              {
                  winnerBox.Text = "O wins!";
              }
  
  
              //X win check
              if (board[0, 0] == 1 &amp;&amp; (board[0, 0] == board[0, 1]) &amp;&amp; (board[0, 1] == board[0, 2]))
              {
                  winnerBox.Text = "X wins!";
              }
              else if (board[1, 0] == 1 &amp;&amp; (board[1, 0] == board[1, 1]) &amp;&amp; (board[1, 1] == board[1, 2]))
              {
                  winnerBox.Text = "X wins!";
              }
              else if (board[2, 0] == 1 &amp;&amp; (board[2, 0] == board[2, 1]) &amp;&amp; (board[2, 1] == board[2, 2]))
              {
                  winnerBox.Text = "X wins!";
              }
              else if (board[0, 0] == 1 &amp;&amp; (board[0, 0] == board[1, 0]) &amp;&amp; (board[1, 0] == board[2, 0]))
              {
                  winnerBox.Text = "X wins!";
              }
              else if (board[0, 1] == 1 &amp;&amp; (board[0, 1] == board[1, 1]) &amp;&amp; (board[1, 1] == board[2, 1]))
              {
                  winnerBox.Text = "X wins!";
              }
              else if (board[0, 2] == 1 &amp;&amp; (board[0, 2] == board[1, 2]) &amp;&amp; (board[1, 2] == board[2, 2]))
              {
                  winnerBox.Text = "X wins!";
              }
              else if (board[0, 0] == 1 &amp;&amp; (board[0, 0] == board[1, 1]) &amp;&amp; (board[1, 1] == board[2, 2]))
              {
                  winnerBox.Text = "X wins!";
              }
              else if (board[0, 2] == 1 &amp;&amp; (board[0, 2] == board[1, 1]) &amp;&amp; (board[0, 1] == board[2, 0]))
              {
                  winnerBox.Text = "X wins!";
              }
          }
  
          private void exitButton_Click(object sender, EventArgs e)
          {
              this.Close();
          }
      }
  }
  </code></pre>