Can someone help me fix this code? C#?

The code is allowing me to put o's on the form, but is not switching between "x" and "o" 

   bool turn = true; // true = X's , false = O's

            int turncount = 0; // this count the numbers of passed turns

            Button b = (Button)sender; // take the properties of the button clicked

            if (turn == true) // if "turn" is true, this means it is X's turn, so we write "X" in the button

                b.Text = "X"; // otherwise we write O

            else

                if (turn == false) // If " turn" is not "true" then we write O

                b.Text = "O";

            turn = !turn;

            turncount++;

            

1 Answer

Relevance
  • User
    Lv 7
    8 months ago

    You don't have a loop.

    There's no looping instruction (while, for, etc.)

    So

    what should happen to THAT program

    is that the program runs only once

    starting out with

    turn = true

    it sets b.Text = "X"

    then it sets turn = false

    adds one to turncount

    and STOPS

Still have questions? Get your answers by asking now.