Instead of just converting the values it would be better to use TryParse to test if the value can be converted and if it can, it'll be converted. Have a look at
Int.TryParse[
^] and
double.TryParse[
^]
Something like
double num2;
if (!double.Parse(TextBox2.Text, out num2)) {
System.Diagnostics.Debug.WriteLine(string.Format("{0} is not a double.", TextBox2.Text));
return;
}
Note that you originally had an extra semicolon in
double num2 = double.TryParse(TextBox2.Text;);