Beispiel #1
0
        private void EqualButton_Click(object sender, RoutedEventArgs e)
        {
            double newNumber;

            if (double.TryParse(resultLabel.Content.ToString(), out newNumber))
            {
                ;

                switch (selectedOperator)
                {
                case SelectedOperator.Addition:
                {
                    result = SimpleMath.Add(lastNumber, newNumber);
                }
                break;

                case SelectedOperator.Subtraction:
                {
                    result = SimpleMath.Subtract(lastNumber, newNumber);
                }
                break;

                case SelectedOperator.Multiplication:
                {
                    result = SimpleMath.Multiply(lastNumber, newNumber);
                }
                break;

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

                default:
                    break;
                }
                resultLabel.Content = result.ToString();
                lastNumber          = result;
                lastLabel.Content   = "";
                lastLabel.Content   = lastNumber.ToString();
            }
        }