How can I check to see if the textbox is empty and then only divide by that number of int
. As you can see now I will divide by 10 everytime so now I need help with error checking.
namespace Assignment1_White
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int num1;
int num2;
int num3;
int num4;
int num5;
int num6;
int num7;
int num8;
int num9;
int num10;
int answer;
num1 = int.Parse(num100.Text);
num2 = int.Parse(num200.Text);
num3 = int.Parse(num300.Text);
num4 = int.Parse(num400.Text);
num5 = int.Parse(num500.Text);
num6 = int.Parse(num600.Text);
num7 = int.Parse(num700.Text);
num8 = int.Parse(num800.Text);
num9 = int.Parse(num900.Text);
num10 = int.Parse(num1000.Text);
answer = (num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 +num10)/10;
MessageBox.Show(answer.ToString());