2016-12-03 6 views
1

コードについて:メソッド名予想されるエラー - C#

私はTIC TAC TOEのゲームのためのWindowsフォームアプリケーションを作っています。これはその中のメソッドの1つです。勝者を対角線、水平、垂直にチェックします。

エラー:& &文の右辺で

、私は、「メソッド名が期待される」というエラーが表示されます。私はエラーを理解することができません。私は誰かが助けることを願っていますif文

 private void checkForwinner() 
     { 
     bool there_is_a_winner= false; 

     //horizontal check 
     if((A1.Text==A2.Text)&& (A2.Text==A3.Text)(!A1.Enabled)) 
     there_is_a_winner=true; 

     else if((B1.Text==B2.Text)&& (B2.Text==B3.Text)(!A2.Enabled)) 
     there_is_a_winner=true; 

     else if ((C1.Text == C2.Text) && (C2.Text == C3.Text)(!A3.Enabled)) 
      there_is_a_winner = true; 

     //Vertical Check 
     else if ((A1.Text == B1.Text) && (B1.Text == C1.Text)(!A1.Enabled)) 
      there_is_a_winner = true; 

     else if ((A2.Text == B2.Text) && (B2.Text == C2.Text)(!B1.Enabled)) 
      there_is_a_winner = true; 

     else if ((A3.Text == B3.Text) && (B3.Text == C3.Text)(!C1.Enabled)) 
      there_is_a_winner = true; 

     //Diagonal Check 
     else if ((A1.Text == B2.Text) && (B2.Text == C3.Text)(!A1.Enabled)) 
      there_is_a_winner = true; 

     else if ((A3.Text == B2.Text) && (B2.Text == C1.Text)(!C1.Enabled)) 
      there_is_a_winner = true; 
     } 
+0

'(A2.Text == A3.Text)(!A1.Enabled)'とはどういう意味ですか?それはあなたの問題だ。 –

答えて

1

あなたはすべてで& &が欠落しています。

また、演算子&&を実行する前に必ず空白を入れてください。コードを読みやすくしてください。

if((A1.Text==A2.Text) && (A2.Text==A3.Text)(!A1.Enabled)) 
     there_is_a_winner=true; 

使用は

if((A1.Text==A2.Text) && (A2.Text==A3.Text) && (!A1.Enabled)) 
     there_is_a_winner=true; 

同様に、内のすべてのif-else文を実行します。

+0

ああ、...答えは感謝です。 – YoMama

+0

@YoMama - あなたも答えをupvoteすることができます。乾杯、:) –

関連する問題