我在运行此程序并使其显示我想要的输出时遇到问题

本文关键字:我想要 输出 问题 遇到 显示 运行 程序 | 更新日期: 2023-09-27 18:35:31

当我尝试运行我的代码时,我收到此消息,我知道它不完整。

错误 1 "CalculateGrossPay_Click"没有重载与委托"System.EventHandler"匹配 C:''Users''Jose A Soto''Desktop''Windows Forms Application''Windows Forms Application3''Form1.Designer.cs 169 WindowsFormsApplication3 46

这是我双击错误时显示的代码行:

这。CalculateGrossPay.Click += new System.EventHandler(this.CalculateGrossPay_Click);

我也无法显示任何内容。

public partial class Form1 : Form
{
    private string name;
    //private decimal;
    //private decimal;
    public Form1()
    {
        InitializeComponent();
    }
    private decimal CalculateGrossPay_Click(decimal hours, decimal rate)
    {
        decimal result=0.00m;
        decimal standardHours= 0.00m;
        decimal overtimeHours=0.00m;
        if (hours > 40)
        {               
            overtimeHours = (hours - 40) * ( (rate) * 1.5m);
            standardHours = 40 * rate;
            DisplayOutPut.Text = name+ NameTextBox.Text + ""; 
            DisplayOutPut.Text = "Gross Pay:" + result;
        }
        else
        {
            standardHours = hours * rate;
            DisplayOutPut.Text = "Hours:" + HoursTextBox.Text;
            DisplayOutPut.Text = "Rate:" + RateTextBox.Text;
        }
        result = standardHours + overtimeHours;
        return result;        
    }
}

我在运行此程序并使其显示我想要的输出时遇到问题

不应更改"单击事件"的委托签名。此处的单击事件处理程序需要与签名匹配的方法。 CalculateGrossPay_Click(Object sender, EventArgs e)

执行以下操作,

private void CalculateGrossPay_Click(Object sender, EventArgs e)
{
    CalculateGrossPay(decimal hrs, decimal rate)      ;
}
public void CalculateGrossPay(decimal hrs, decimal rate)
{
    //write your logic here, if you want to return some value, chnage return type
}