gpt4 book ai didi

c# - 选中 CheckBox 时如何添加整数值?

转载 作者:行者123 更新时间:2023-11-30 20:14:56 25 4
gpt4 key购买 nike

我希望在选中复选框时将值添加到整数 (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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com