我希望在选中复选框时将值添加到整数 (int priceTotal)。该练习用于在网络表单中订购披萨。我希望能够根据选择的尺寸和浇头添加到总价中。
int priceTotal = 0;
if (smallPizzaCheck.Checked)
{
priceTotal + 10;
}
else if (mediumPizzaCheck.Checked)
{
priceTotal + 13;
}
//Et cetera, et cetera
orderTotal.Text = Convert.ToString(priceTotal);
最佳答案
int priceTotal = 0;
if (smallPizzaCheck.Checked)
{
priceTotal = priceTotal + 10;
}
else if (mediumPizzaCheck.Checked)
{
priceTotal = priceTotal + 13;
}
//Et cetera, et cetera
orderTotal.Text = Convert.ToString(priceTotal);
Just try this....whenever check box checked...the price total added..again and again... so you can sum into (priceTotal value) and display into textbox name("orderTotal.Text")
关于c# - 选中 CheckBox 时如何添加整数值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58003896/