I was making a simple addition calculator in C# and I am getting a run-time error. When I press the button, I get an error at the
double no1d = Double.Parse( no1 ) ;
line.
The error says
Exception thrown: 'System.FormatException' in mscorlib.dll Additional information: Input string was not in a correct format.
using System;
using System.Windows.Forms;
namespace Addition
{
public partial class Addition : Form
{
public Addition()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string no1 = label1.Text;
double no1d = Double.Parse( no1 )
string no2 = label2.Text;
double no2d = Double.Parse( no2 ) ;
double result = no1d + no2d;
label3.Text = result.ToString() ;
}
private void label3_Click(object sender, EventArgs e)
{
}
}
}
What can I do to correct the error ?
The values of label one and label two are just useless.
Edit: I found the answer now. Dimitry Bychenko was right....I had made the stupid mistake of writing 'label1' instead of 'textbox'.