title: Passing an argument to a method in C#
body: <p>So, this program functions as it should, but I don't think the code is very "clean," so I'm looking for suggestion.  Two of the big issues I have:</p>
  
  <ol>
  <li><p>For the method public double temperatureInFahrenheit, I want to pass the argument celsiusTemperature to the function instead of having to redeclare the variable, convert it from the text to the double, etc.  Whenever I attempt to try that I get an error in the MessageBox.Show when I try to call the function myAirport.temperatureInFahrenheit (I don't specifically remember what the error is, so I'll have to recode if that's needed).  Any thoughts on what I can do to make this work?</p></li>
  <li><p>The MessageBox.Show in the public partial class Form1 seems like messy code to me.  What I'd like to do is write a method in internal class Airport, where the necessary arguments are passed to the method, and then just do something like MessageBox.Show(myAirport.message()), but I'm assuming if I tried that I'd get the same error as I'm getting for 1.  Any thoughts?</p></li>
  </ol>
  
  <p>Again, the code is completely functional and works and meets the required specifications, but I don't like just having functional code, I like having functional code that's "pretty."  Note: I don't have comments for any of the methods, variables, etc.  I'm putting those in right now, but thought I'd try and get some feedback first.</p>
  
  <pre><code>public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          string airportName;
          double celsiusTemperature, elevation;
  
  
          if (String.IsNullOrEmpty(txtAirport.Text)) {
              MessageBox.Show("You did not enter a name for the airport.  Please enter a name for the airport.");
              return;
          } else
          {
              airportName = Convert.ToString(txtAirport.Text);
          }
          if (Double.TryParse(txtTemperature.Text, out celsiusTemperature))
          {
              if (celsiusTemperature &gt; 50 || celsiusTemperature &lt; -50)
              {
                  MessageBox.Show("The value you entered for temperature is outside the acceptable range.  Please reenter the information");
                  Application.Restart();
              }
          }
          else
          {
              MessageBox.Show("You did not enter a numeric value for the temperature.  Please enter a valid, i.e. numeric, value for the temperature.");
              return;
          }
          if (Double.TryParse(txtElevation.Text, out elevation))
          {
              if (elevation &gt; 12000 || elevation &lt; -300)
              {
                  MessageBox.Show("The value you entered for elevation is outside the acceptable range.  Please reenter the information.");
                  Application.Restart();
              }
          }
          else
          {
              MessageBox.Show("You did not enter a numeric value for the elevation.  Please enter a valid, i.e. numeric, value for the elevation.");
              return;
          }
  
          Airport myAirport = new Airport(airportName, celsiusTemperature, elevation);
  
          MessageBox.Show("The airport name is: " + myAirport.airportName(airportName) + Environment.NewLine + "The Celsius temperature is: " + myAirport.celsiusTemperature(celsiusTemperature)
              + Environment.NewLine + "The Fahrenheit temperature is: " + myAirport.temperatureInFahrenheit(celsiusTemperature) + Environment.NewLine + "The elevation is: " + myAirport.elevation(elevation));
  
      }
  
      private void button2_Click(object sender, EventArgs e)
      {
          Close();
      }
  
  }
  
  internal class Airport
  {
      private string airportName1;
      private double celsiusTemperature1;
      private double elevation1;
  
      public Airport(string airportName1, double celsiusTemperature1, double elevation1)
      {
          this.airportName1 = airportName1;
          this.celsiusTemperature1 = celsiusTemperature1;
          this.elevation1 = elevation1;
      }
  
      public string airportName(string airportName1)
      {
          return airportName1;
      }
  
      public double celsiusTemperature(double celsiusTemperature1)
      {
         return celsiusTemperature1;
      }
  
      public double elevation(double elevation1)
      {
          return elevation1;
      }
  
      public double temperatureInFahrenheit(double celsiusTemperature1)
      {
  
          double fahrenheitTemperature = 0;
  
          fahrenheitTemperature = celsiusTemperature1 * (1.8) + 32;
  
          return fahrenheitTemperature;
      }
  
  }
  }
  </code></pre>