住院:我找不到我的 CalcTotalChargs 未被识别的原因

Hospital Stay: I cannot find a reason why my CalcTotalChargs is not being recognized

这应该有效,因为尽管被声明为最后一个私有双精度值,但 C# 的模块化应该也允许第一个 CalcTotalChargs 被识别。这使我无法 运行 程序成功

这是我目前的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace Adam_Zeidan_HW7CH6_6_Hospital_Stay
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void calculateButton_Click(object sender, EventArgs e)
        {
            *label6.Text = "You will be paying: " +         **CalcTotalChargs()**.ToString("c");*
        }

        private int CalcStayCharges()
        {
            return (350 * int.Parse(textBox1.Text));        // Calculating     the amount of days by 0
        }
        private double CalcMiscCharges()
        {
            return double.Parse(textBox2.Text) + double.Parse(textBox3.Text) +    
                double.Parse(textBox5.Text) + double.Parse(textBox5.Text);          // Adding together the other values entered within the textboxes to add to the eventual total charge
        }
        private double CalcTotalCharges()
        {
            return CalcMiscCharges() + CalcStayCharges();       // Adding     the number value of the sum of the previous calculation to the sum of the 350 *     Number of days staying
        }
    }
}

您的函数拼写错误,因此无法完成。

CalcTotalChargs().ToString("c") 应该是 CalcTotalCharges().ToString("c")

使用下面的代码应该可以解决问题。

    private void calculateButton_Click(object sender, EventArgs e)
    {
        label6.Text = "You will be paying: " +         CalcTotalCharges().ToString("c");
    }