c# - 必须声明一个主体,因为它没有标记为抽象、外部或部分 C#

标签 c# declare

关于为什么我会收到此错误有什么想法吗?我知道这可能是一个简单的修复,但我对 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/

相关文章:

TypeScript - 声明与导出 - 最佳实践?

c++ - 错误: 'varName' was not declared in this scope

javascript - 我可以在 JavaScript 的不同 for 循环中声明同一个变量两次吗?

c# - "final"在 IL 中是什么意思?

c# - 非 WPF 应用程序中的隐式 WPF 样式

java - eclipse "can not be resolved to variable"

android - 哪个才是真正的androidmanifest.xml?

c# - 我怎样才能在 C# 中获得 C+ +'s "const"的等价物?

c# - 如何在代码隐藏中引发列表控件 SelectedIndexChanged 事件?

c# - Always Freeze 使用 AutoFixture、XUnit 和 Moq 进行模拟