各位大哥大姐,我写了个小程序,但是运行时说“应输入类型 命名空间或文件尾。”就是最后还多一个“}”,不知道怎么办,什么意思啊?求解!!!

解决方案 »

  1.   

    贴点代码~~~~
    是不是你定义方法的时候只写了private void mymethod{....}而没有写()或者没有输入完毕}呢根据提示自己检查一下或者贴点代码上来吧,估计是你粗心出的问题
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                int num1, num2, sum;
                num1 = int.Parse(textBox1 .Text );
                num2 = int.Parse(textBox2.Text);
                sum = num1 / num2;
                textBox3.Text = sum.ToString();        }        private void button3_Click(object sender, EventArgs e)
            {
                int a;
                a = int.Parse(textBox7.Text);
                if (a%2 ==0){
                MessageBox.Show(a.ToString() +"a is 偶数");
                }
                else { 
                MessageBox .Show(a.ToString() +"a is 奇数");
                }
            }        private void button4_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }        private void button5_Click(object sender, EventArgs e)
            {
                int a, b;
                a = int.Parse(textBox8.Text);
                if (a > 100 || a < 0)
                {
                    textBox9.Text = "成绩输入有误";
                }
                else
                {
                    b = a / 10;                switch (b)
                    {
                        case 10:
                        case 9:
                            textBox9.Text = "成绩优秀";
                            break;
                        case 8:
                        case 7:
                        case 6:
                            textBox9.Text = "成绩及格";
                            break;
                        default:
                            textBox9.Text = "成绩不及格";
                            break;
                    }
                }        }        private void button6_Click(object sender, EventArgs e)
            {
                int y, m, d;
                int sum;
                y = int.Parse(textBox10.Text );
                m = int.Parse(textBox11.Text );
                d = int.Parse(textBox12.Text );
                if (y < 1 || y > 9999)
                {
                    textBox13.Text = "请输入正确的年份";
                    textBox10 = "";
                    textBox10 .Focus ();
                    goto count;            }
                else if (m < 1 || m > 12)
                {
                    textBox13.Text = "请输入正确的月份";
                    textBox11 = "";
                     textBox11 .Focus ();
                    goto count;
                }
                else
                {
                    switch (m)
                    {
                        case 2:
                            if ((y % 100 != 0 && y % 4 = 0) || (y % 400 = 0 ))
                            {
                                if (d<1||d>29)
                                {
                                    textBox13.text="闰年2月只有29天请输入正确的天数!";
                                    textBox11 = "";
                                     textBox11 .Focus ();
                                      goto count;
                                }
                                 
                                    else 
                                        if (d<1||d>28)
                                        {
                                             textBox13.text="平年2月只有28天请输入正确的天数!";
                                             textBox11 = "";
                                             textBox11 .Focus ();
                                            goto count;
                                        }                                   
                                    }                                break ;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                    if (d>30||d<1)
                                    {
                                        textBox13.text="有30天请输入正确的天数!";
                                             textBox12 = "";
                                             textBox12 .Focus ();
                                            goto count;
                                    }
                                    break ;
                                    default :
                                    if (d >31||d<1)
                                    {
                                        textBox13.text="只有31天请输入正确的天数!";
                                             textBox12 = "";
                                             textBox12 .Focus ();
                                            goto count;
                                    }
                                    break ;                         }
                                if (m==1||m==2)
                                {sum =(m-1)*31+d ;}                else {
                                    switch (m)
                                    {
                                        case 9:
                                        case 11:
                                            sum =(m -1)*30+d -2+m/2+1;
                                            break ;
                                        default :
                                            sum =(m-1)*30+d -1+m/2;
                                            break ;
                                    }
                                     if ((y % 100 != 0 && y % 4 = 0) || (y % 400 = 0 ))
                                         sum =sum+1;                            }
                    textBox13.Text =y+"年"+m +"月"+d +"日为"+y +"年的第"+sun +"天";
                count:;                }            }
            }
        }
    }