如何用csharp(c#)语言编这样一个Windows窗口程序?

2025-01-06 16:21:36
推荐回答(4个)
回答1:

checked
{
try
{
TextBox3.Text = double.Parse(textBox1.Text)+double.Parse(textBox2.Text);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}

回答2:

private void button1_Click(object sender, EventArgs e)
{
int sum= Convert.ToInt32(textBox1.Text) + Convert.ToInt32(textBox2.Text);
textBox3.Text = sum.ToString();
}

回答3:

private void button1_Click(object sender, EventArgs e)
{
int add = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);
textBox3.Text = add.ToString();
}

回答4:

创建个winform程序
从设计视图的工具箱中拖拽3个TextBox和1个Button
双击Button,进入Button的Click事件,写代码:
try
{
TextBox3.Text = (int.Parse(textBox1.Text)+int.Parse(textBox2.Text)).ToString();
}
catch
{
MessageBox.Show("输入的数字格式不正确");
}