title: c# text box - Accept only floating point numbers inside a range
body: <p>Whenever the user tries to enter a number not in the range <code>[0, 24]</code> it should show an error message. My code to accept floating point numbers is as follows. How can I modify it to add range validation?</p>
  
  <pre><code>private void h(object sender, Windows.UI.Xaml.Controls.TextChangedEventArgs e)
  {        
     try
     {
        float time = float.Parse(hours.Text);
     }
     catch
     { 
        label2.Text = "enter proper value ";
        hours.Text = " ";
     } 
  }
  </code></pre>