我无法弄清楚为什么代码格式错误。我得到了错误TotalTicketprice = decimal.Parse(overallTicketCostlabel.Text);
以及与之相关的所有内容。有谁知道这个的解决方案?
private void calculateButton_Click(object sender, EventArgs e)
{
int Tickets; //Quantity of Tickets
decimal Price; //price per ticket
decimal DiscountPercent = 0.1m; // Discount given
decimal TotalTicketprice; //Ticket price before discount given
decimal Discount;
Tickets = int.Parse(ticketQuantityTextBox.Text);
Price = decimal.Parse(priceTicketTextBox.Text);
TotalTicketprice = decimal.Parse(overallTicketCostlabel.Text);
Discount = decimal.Parse(initialDiscountLabel.Text);
//Ticket Price
overallTicketCostlabel.Text = (Price * Tickets).ToString("c");
//Displays Discount
initialDiscountLabel.Text = (TotalTicketprice * DiscountPercent).ToString("c");
//Displays Discounted Total Cost
discountedCostLabel.Text = (TotalTicketprice - Discount).ToString("c");