private void CalculateSolution(IntegralMethod method, out double?solution) { try { double a = Convert.ToDouble(textBox1.Text), b = Convert.ToDouble(textBox2.Text); int n = Convert.ToInt32(numericUpDown1.Value); solution = func.CalculateDeterminedIntegral(method, a, b, n); } catch (InvalidCastException exp) { solution = null; MessageBox.Show(exp.Message); } }