Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 其他信息:输入字符串的格式不正确_C#_Winforms_Exception_Input - Fatal编程技术网

C# 其他信息:输入字符串的格式不正确

C# 其他信息:输入字符串的格式不正确,c#,winforms,exception,input,C#,Winforms,Exception,Input,我正试图让这个程序工作,但没有骰子。我认为它很完美,但缺少了一些东西。它应该根据购票数量和购票类型显示门票价格,然后显示所有门票的价格和总收入 namespace stadiumApp { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void label7_Clic

我正试图让这个程序工作,但没有骰子。我认为它很完美,但缺少了一些东西。它应该根据购票数量和购票类型显示门票价格,然后显示所有门票的价格和总收入

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

        private void label7_Click(object sender, EventArgs e)
        {
        }

        private void calculateRevenue_Click(object sender, EventArgs e)
        {
           //assigns input to saved memory 
                string inputA="";
                string inputB ="";
                string inputC ="";

                double ticketsPurchasedB = double.Parse(inputB);
                double ticketsPurchasedA = double.Parse(inputA);
                double ticketsPurchasedC = double.Parse(inputC);

               //price of each ticket grade
                double priceA = 15;
                double priceB = 12;
                double priceC = 9;

                //calculations for each class
                double calcOutputA = priceA * ticketsPurchasedA ;
                string outputA = calcOutputA.ToString();

            double calcOutputB = priceB * ticketsPurchasedB;
            string outputB = calcOutputB.ToString();

            double calcOutputC = priceC * ticketsPurchasedC;
            string outputC = calcOutputC.ToString();

           //calculations for total revenue
         double totalLabelHolder = calcOutputA + calcOutputB + calcOutputC;
           //display total 
            string totalLabel = totalLabelHolder.ToString();
      }
   }
}

您需要在表单上创建文本框并使用其值,而不是:

string inputA="";
string inputB ="";
string inputC ="";
这些行中的每一行都将抛出一个错误(因为您无法将空字符串解析为double):


这个问题陈述不是很具体。请包括你正在得到的错误,什么是不工作的,等等。对于一些代码,我们只能说“是的,工作如所写”。把它简化为一个简单的例子,解释你想要/期望什么,你得到了什么,你尝试了什么。
double ticketsPurchasedB = double.Parse(inputB);
double ticketsPurchasedA = double.Parse(inputA);
double ticketsPurchasedC = double.Parse(inputC);