none
Tic Tac Toe Game in C# visual 2012 RRS feed

  • Question

  • Hi, I am using visual 2012 c#. and making a tic tac toe game for windows 8.there is a logical error on the "IF statement" .any one can help me.what type of logical error occurred and how to resolve it.because when it is executed its not display the message box that player x wins...... 

    private

    voidwin()

            

    {

      

    if(button1.Content == "X"&& button2.Content=="X"&& button3.Content=="X")

    {

                   

    MessageBox.Show("Player X wins!");

    button1.Content=

    "";

    button2.Content=

    "";

    button3.Content=

    "";

    button4.Content=

    "";

    button5.Content=

    "";

    button6.Content=

    "";

    button7.Content=

    "";

    button8.Content=

    "";

    button9.Content=

    "";

    }

    Saturday, November 3, 2012 1:12 PM

Answers

  • You may just have to add parethesis.  I don't know what type of object your buttons are so I'm not sure of the answer.  If the button object has TEXT I would use Text instead of contenets.

    if((button1.Content == "X") && (button2.Content=="X") && (button3.Content=="X"))


    jdweng

    Saturday, November 3, 2012 2:42 PM