private async void equalButton_Click(object sender, EventArgs e) { if (isNewOperation) { return; } try { _numbers[1] = Convert.ToInt32(textBox.Text); } catch (Exception) { return; } var operation = MathOperationFactory.GetMathOperation(_operationKey); decimal result; try { result = await operation.Calculate(_numbers); } catch (MathOperationException ex) { textBox.Text = ex.Message; _numbers = new int[2]; return; } isNewOperation = true; textBox.Text = result.ToString(); }
private void fibButton_Click(object sender, EventArgs e) { var operation = MathOperationFactory.GetMathOperation("fib"); _numbers[0] = Convert.ToInt32(textBox.Text); textBox.Text = operation.Calculate(_numbers).Result.ToString(); isNewOperation = true; }