title: How do I check if a number in a textbox is greater than a predefined value
body: <p>im doing an exercise where i have to make a parking lot application.
  The objectives are: Create a form with a numericUpDown control for choosingthe amount of time a vehicle was parked. Add option buttons to show if the vehicle is a car or truck. Clearly label each box and button. Add a label or text box to show the amount to pay.</p>
  
  <p>Also, i have to set some limits. Cars shouldn't pay more than $38.00 for 24 hours, and trucks no more than $44.50 for 24 hours.</p>
  
  <p>The only problem i find is that i cannot set these limits. It gives an error: Use of unassigned local variable 'result' .</p>
  
  <p>Check the commented /// code.</p>
  
  <p>Any help much appreciated. It's not a schoolwork project, i'm just learning c# by myself and doing some exercises.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>        private void calculate_Click(object sender, EventArgs e)
      {
          double carhours = 3;
          double truckhours = 3.50;
          double carFirsthour = 5;
          double truckFirsthour = 6;
          int hrs = (int)numericUpDown.Value;
          double result;
          int maxCarFee = 38;
  
  
          if (numericUpDown.Value &lt; 1)
          {
              MessageBox.Show("NO WAY");
              return;
          }
  
          if (carButton.Checked == true &amp;&amp; (numericUpDown.Value == 1))
          {
              result = (hrs * carFirsthour);
              fee.Text = "$" +  result;
          }
  
          if (carButton.Checked == true &amp;&amp; (numericUpDown.Value &gt; 1))
          {
              result = ((hrs - 1) * carhours + carFirsthour);
              fee.Text = "$" + result;
          }
  
          if (truckButton.Checked == true &amp;&amp; (numericUpDown.Value == 1))
          {
              result = (hrs * truckFirsthour);
              fee.Text = "$" + result;
          }
  
          if (truckButton.Checked == true &amp;&amp; (numericUpDown.Value &gt; 1))
          {
              result = ((hrs - 1) * truckhours + truckFirsthour);
              fee.Text = "$" + result;
          }
  
          /// limits
  
          ///if (carButton.Checked == true &amp;&amp; (numericUpDown.Value &lt; 24) &amp;&amp; (result &gt; maxCarFee))
          ///{
          ///    fee.Text = "$" + maxCarFee;
          ///}
      }
  </code></pre>