有关我为什么会收到此错误的任何想法?我知道这可能是一个简单的修复,但我是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);
}
}
感谢。
答案 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没有正文!