标点符号预期错误-c#

时间:2012-10-07 11:22:36

标签: c# punctuation

我是c#的新手。我正在编写基本的平均计算器。我发现大多数错误60个

)预期

预期

我检查过,但我认为每一件事都是正确的。可以解决我使用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";
                }


        }



        }

2 个答案:

答案 0 :(得分:2)

代码中有HTML实体,您必须将其转换回真实字符。

例如:

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

应该是:

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

答案 1 :(得分: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";
}