namespace Calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Calculate_Click(object sender, EventArgs e)
{
int num1 = Convert.ToInt32(Number1.Text);
int num2 = Convert.ToInt32(Number2.Text);
int result = 0;
string resultString = Convert.ToString(result);
if (Addition.Checked == true)
{
result = num1 + num2;
resultBox.Text = resultString;
}
else if (Subtraction.Checked == true)
{
result = num1 - num2;
resultBox.Text = resultString;
}
else if (Multiplication.Checked == true)
{
result = num1 * num2;
resultBox.Text = resultString;
}
else
{
resultBox.Text = "Error, no parameter selected";
}
}
}
}
I'm pretty sure that most of it is right, it seems to be the converting that is tripping me up. I'm new to C# (first day!) so i'm a bit confused. Also first post on this website, so sorry for any formatting problems.