private void resultButton_Click(object sender, RoutedEventArgs e) { //Checks which operation was used, and after calculates it by using another "SimpleMath" class double newNumber; if (double.TryParse(resultLabel.Content.ToString(), out newNumber)) { switch (selectedOperator) { case SelectedOperator.Addition: result = SimpleMath.add(lastNumber, newNumber); break; case SelectedOperator.Substraction: result = SimpleMath.substract(lastNumber, newNumber); break; case SelectedOperator.Multiplication: result = SimpleMath.multiply(lastNumber, newNumber); break; case SelectedOperator.Division: result = SimpleMath.divide(lastNumber, newNumber); break; } resultLabel.Content = result.ToString(); } }