namespace WindowsFormsApplication5{ public partial class Form1 : Form { public Form1() { InitializeComponent(); label5.Text = string.Empty; label1.Text = string.Empty; label3.Text = string.Empty; } Random rnd = new Random(); private int first; private int second; private void RndSet() { first = rnd.Next(1, 100); second = rnd.Next(1, 100); label1.Text = first.ToString(); label3.Text = second.ToString(); label5.Text = string.Empty; } private void button2_Click(object sender, EventArgs e) { RndSet(); } private void button1_Click(object sender, EventArgs e) { int calValue = 0; if (int.TryParse(textBox1.Text, out calValue)) { if (first + second == calValue) { label5.Text = "对"; } else { label5.Text = "错"; } } } private void Form1_Load(object sender, EventArgs e) { RndSet(); } }}
目前暂无任何回答
- 0 回答
- 0 关注
- 1319 浏览
添加回答
举报
0/150
提交
取消