Это СЛЕДУЕТ работать, потому что, несмотря на то, что он объявлен последним частным двойником, модуляция C# должна позволять распознавать первые CalcTotalChargs. Это мешает мне запустить программу успешноПребывание в больнице: я не могу найти причину, по которой мои 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 $350
}
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
}
}
}
Вы можете сообщить об ошибке? Поскольку это означает, что ваш код работает отлично для меня, и я не могу воспроизвести проблему (если таковой имеется). – Gabe
Несомненно! ошибка находится в строке «label6.Text =». Вы будете платить: «+ CalcTotalChargs(). ToString (« c »); Visual Studio C# не распознает CalcTotalChargs() и говорит, что она не существует в текущем контексте. –