- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WinForm2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string str1 = textBox1.Text;
- string str2 = textBox2.Text;
- int i1, i2;
- if (!int.TryParse(str1, out i1))
- {
- MessageBox.Show("text1 is not a real number");
- textBox1.Text = "";
- textBox2.Text = "";
- return;
- }
- if (int.TryParse(str2, out i2) == false)
- {
- MessageBox.Show("text2 is not a real number");
- textBox1.Text = "";
- textBox2.Text = "";
- return;
- }
- int i3 = i1 + i2;
- textBox3.Text = Convert.ToString(i3);
- }
- }
- }