必须声明一个正文,因为它没有标记为abstract,extern或partial c#

时间:2013-04-08 09:33:45

标签: c# declare

有关我为什么会收到此错误的任何想法?我知道这可能是一个简单的修复,但我是C#的新手,我无法找到任何修复。

'SimpleMath.UI.Add_operation.btnCalculate_Click(object,System.EventArgs)'必须声明一个正文,因为它没有标记为abstract,extern或partial

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


namespace SimpleMath.UI
{
    class Add_operation
    {
        public string Calculate(decimal i, decimal j)
        {
            return (i + j).ToString();
        }
        private void btnCalculate_Click(object sender, EventArgs e);

    }
}

感谢。

2 个答案:

答案 0 :(得分:2)

您需要在btnCalculate_Click方法中声明正文

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

namespace SimpleMath.UI
{
    class Add_operation
    {
        public string Calculate(decimal i, decimal j)
        {
            return (i + j).ToString();
        }

        private void btnCalculate_Click(object sender, EventArgs e)
        {
           // do some stuff here
           // or remove the method if it's empty
        }
    }
}

答案 1 :(得分:0)

错误很明显。你的方法btnCalculate_Click没有正文!