【问题标题】:Type or namespace definition error类型或命名空间定义错误
【发布时间】:2013-04-08 00:06:38
【问题描述】:

我是论坛和编码的新手,这是一个我还没有看到的错误,据我所知,我已经正确地包含了我的方法和类,但我仍然收到以下 2 个错误:

  1. } 预期
  2. 类型或命名空间定义,或预期的文件结尾。

    namespace Assignment15Start
    {
        public partial class GradebookForm : Form
        {
            private Student betty;
    
            public GradebookForm()
            {
                InitializeComponent();
            }
    
            private void addStudentButton_Click(object sender, EventArgs e)
            {
                betty = new Student() {Name = "Lisa", Id = 55555};
                //betty.SingleCourse.AssignmentCreate();
    
                private void Grade()
                {
                    double grade;
                    grade = betty.SingleCourse.CalcGrade()*100;
                    MessageBox.Show("Your grade is " + grade);
                }
             }
        }
    }
    

【问题讨论】:

    标签: c# namespaces


    【解决方案1】:

    您在addStudentButton_Click 方法中定义Grade() 方法。

    你不能那样做;方法不能嵌套。 (匿名方法除外)

    【讨论】:

      猜你喜欢
      • 2013-11-11
      • 1970-01-01
      • 1970-01-01
      • 2014-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-24
      相关资源
      最近更新 更多