title: Get variable from other function
body: <p>Let's say I have the following code:</p>
  
  <pre><code>protected void ReservationForm()
  {
  double x = 50;
  double tva = 1.196;
  double totalAmount = 0;
  
  totalAmount = x * tva;
  
  ltrl_showText = "Total Amount is " + totalAmount;
  }
  
  protected void btn_submit_Click(object sender, EventArgs e)
  {
  ltrl_previewText = "You ordered nameProduct at the price of " + totalAmount ;
  }
  </code></pre>
  
  <p>How can I get the variable totalAmount from the function above?</p>
  
  <p>I know that with Java I can do this with <code>super()</code> and I found that the equal property on C# is <code>base</code> but I don't know how to use it. I tried to change the function to public instead of protected but I always get an error.</p>
  
  <p>Thanks for your time.</p>
  
  <p>EDIT: I use AJAX, that's why the total Amounts are on both functions. The first one I need it because the total amount changes depending the user selection and then on click he sees the preview page.</p>