关于为什么我会收到此错误有什么想法吗?我知道这可能是一个简单的修复,但我对 C# 完全陌生,并且无法找到任何修复。
“SimpleMath.UI.Add_operation.btnCalculate_Click(object, System.EventArgs)”必须声明一个主体,因为它未标记为“抽象”、“外部”或“部分”
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);
}
}
谢谢。
最佳答案
您需要在 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
}
}
}
关于c# - 必须声明一个主体,因为它没有标记为抽象、外部或部分 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15875789/