/// <summary> /// Checks wether the inputed text is numeric and then calculate the inputed number factorial /// </summary> private void calculateBtn_Click(object sender, RoutedEventArgs e) { Console.WriteLine(Mode); int n; bool isNumeric = int.TryParse(FactorialValueTextBox, out n); if (isNumeric) { FactorialResult = Mathematics.Factorial(n); } }
public Factorial(double mode) { InitializeComponent(); DataContext = this; try { Mode = mode; FactorialResult = Mathematics.Factorial((int)Mode); } catch (InvalidCastException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } }