a C# beginner here. I've been following a guide on making a simple calculator. Everything worked fine 'till I added the point button. If I use the calculator to calculate basic integers there's no problem. However, when I add in the point button to calculate doubles with a decimal it gets all screwed up. Any ideas?
// Above this are the numeric buttons, no problem with those
private void btnPoint_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnPoint.Text;
}
double total1 = 0;
double total2 = 0;
private void btnPlus_Click(object sender, EventArgs e)
{
total1 = total1 + double.Parse(txtDisplay.Text); // Error comes here
txtDisplay.Clear();
}
private void btnEquals_Click(object sender, EventArgs e)
{
total2 = total1 + double.Parse(txtDisplay.Text); // And one time it came here
txtDisplay.Text = total2.ToString();
total1 = 0;
}