private void gen_btn_Click(object sender, RoutedEventArgs e) { if (number_tb.Text != string.Empty) { str = number_tb.Text; try { double upperBound = Double.Parse(str); result_tbl.Text = String.Format("{0:0.##}", mr.GetRandomNum(upperBound)).ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
static void Main(string[] args) { MyRandomizer mr = new MyRandomizer(); string str; do { Console.WriteLine("Enter a number for the Upper Bound: "); str = Console.ReadLine(); try { double upperBound = Double.Parse(str); Console.WriteLine("Random number between 0 and {1}: {0}", mr.GetRandomNum(upperBound), upperBound); } catch (Exception e) { } }while (str != "exit"); Console.WriteLine("\nHit Enter key to continue..."); Console.ReadLine(); }