2012-10-07 131 views
-1

我是新來的C#。我試圖寫基本平均calculator.I得到60錯誤大多標點符號錯誤預期-C#

)預計

;預計

我檢查了但我認爲everythıngs correct.Can它是問題,我使用Visual Studio 2010?

using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Drawing; 
    using System.Linq; 
    using System.Text; 
    using System.Windows.Forms; 

    namespace WindowsFormsApplication3 
    { 

      public partial class Form1 : Form 
     { 
      public Form1() 
      { 
       InitializeComponent(); 
      } 

      private void button1_Click(object sender, EventArgs e) 
      { 
       double a; 
       a = ((Convert.ToInt16(textBox1.Text) * 0.4) + (Convert.ToInt16(textBox2.Text) * 0.6)); 
       if (a >= 50 & a < 60 & Convert.ToInt64(textBox2.Text) >= 50) 
       { 
        label4.Text = "Geçti"; 
        label5.Text = "CC"; 
        textBox3.Text = a.ToString(); 
       } 

       else 
       { 
        label4.Text = "KALDI"; 
        label5.Text = "FF"; 
        textBox3.Text = a.ToString();    
       } 

      } 



       private void button2_Click_1(object sender, EventArgs e) 
       { 
       textBox1.Text = ""; 
       textBox2.Text = ""; 
       textBox3.Text = ""; 
       label4.Text = "Durum"; 
       label5.Text = "Sonuc"; 
       } 


     } 



     } 
+3

" "; ..?那裏有那些事情呢? – Thousand

+0

你從網上覆制/粘貼這段代碼嗎? –

+0

是ı從網絡複製 – allstar

回答

2

您在代碼中有HTML實體,您必須將其轉換回真實的字符。

這例如:

if (a >= 50 & a < 60 & Convert.ToInt64(textBox2.Text) >= 50) 

應該是:

if (a >= 50 & a < 60 & Convert.ToInt64(textBox2.Text) >= 50) 
+0

非常感謝你 – allstar

0
private void button1_Click(object sender, EventArgs e) 
{ 
    double a; 
    a = ((Convert.ToInt16(textBox1.Text) * 0.4) + (Convert.ToInt16(textBox2.Text) * 0.6)); 
    if (a >= 50 && a < 60 && Convert.ToInt64(textBox2.Text) >= 50) 
    { 
     label4.Text = "Ge&ccedil;ti"; 
     label5.Text = "CC"; 
     textBox3.Text = a.ToString(); 
    } 
    else 
    { 
     label4.Text = "KALDI"; 
     label5.Text = "FF"; 
     textBox3.Text = a.ToString();    
    } 
} 

private void button2_Click_1(object sender, EventArgs e) 
{ 
    textBox1.Text = ""; 
    textBox2.Text = ""; 
    textBox3.Text = ""; 
    label4.Text = "Durum"; 
    label5.Text = "Sonuc"; 
}