【发布时间】:2016-11-18 03:52:29
【问题描述】:
我正在构建这三个文本框,如果两个文本框被填充,那么当我输入 10 + 10 时,将显示总和。结果是 1010。有人可以帮我解决这个问题吗?
这是我的代码:
public void textBoxTranspo_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(textBoxTranspo.Text) && !string.IsNullOrEmpty(textBoxDaily.Text))
textBoxTotalAmount.Text = (Convert.ToInt32(textBoxTranspo.Text) + Convert.ToInt32(textBoxDaily.Text).ToString());
}
public void textBoxDaily_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(textBoxTranspo.Text) && !string.IsNullOrEmpty(textBoxDaily.Text))
textBoxTotalAmount.Text = (Convert.ToInt32(textBoxTranspo.Text) + Convert.ToInt32(textBoxDaily.Text).ToString());
}
【问题讨论】:
标签: c# .net winforms int type-conversion