Ejemplo n.º 1
0
        private void BtnEquals_Click(object sender, RoutedEventArgs e)
        {
            double newNumber;

            if (double.TryParse(lblResult.Content.ToString(), out newNumber))
            {
                switch (selectedOperator)
                {
                case SelectedOperator.Addition:
                    result = SimpleMath.Add(lastNumber, newNumber);
                    break;

                case SelectedOperator.Subtraction:
                    result = SimpleMath.Minus(lastNumber, newNumber);
                    break;

                case SelectedOperator.Multiplication:
                    result = SimpleMath.Times(lastNumber, newNumber);
                    break;

                case SelectedOperator.Division:
                    result = SimpleMath.Divide(lastNumber, newNumber);
                    break;
                }
            }

            lblResult.Content = result.ToString();
        }