Input string was not in a correct format in double.Parse

Also remember that the Parse method is relying on the culture of your operating system to perform the conversion, so try to change your code to

num2 = double.Parse(textBox1.Text, CultureInfo.InvariantCulture);

You might also consider to use the

double.TryParse

method for better exception handling.

Leave a Comment