void handler(object sender, EventArgs args) { UIButton button = (UIButton)sender; UpdateButton(button, "X", false); //update the user selected button("X") tictactoe.SetChoice(1, (int)button.Tag); //set user's choice //int result = tictactoe.CheckWin(); int result = CheckResult(0); //check the result of user's choice if (result == 0) //if the game is not over yet, get the computer choice { //get the computer choice int compChoice = tictactoe.ComputerChoice(); //update a Button of computer choose switch (compChoice) //update the button that computer choose ("O") { case 1: UpdateButton(Button1, "O", false); break; case 2: UpdateButton(Button2, "O", false); break; case 3: UpdateButton(Button3, "O", false); break; case 4: UpdateButton(Button4, "O", false); break; case 5: UpdateButton(Button5, "O", false); break; case 6: UpdateButton(Button6, "O", false); break; case 7: UpdateButton(Button7, "O", false); break; case 8: UpdateButton(Button8, "O", false); break; case 9: UpdateButton(Button9, "O", false); break; default: break; } result = CheckResult(1); //check the result of computer's choice } }