using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace add
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int x = int.Parse(textBox1.Text);
int y = int.Parse(textBox2.Text);
int z = x + y;
textBox3.Text = z.ToString();
}
}
}
float i = 0;
float j = 0;
aa:Console.WriteLine("请输入一个数!");
try
{
i = float.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("你输入的不是一个数,请重新输入!");
goto aa;
}
bb:Console.WriteLine("请再次输入一个数!");
try
{
j = float.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("你输入的不是一个数,请重新输入!");
goto bb;
}
sum = i + j;
Console.WriteLine("{0}+{1}={2}",i,j,sum);
Console.ReadLine();
我调试了下,可以运行,出错也给处理了,还有问题M我