title: How do I use a variable declared in a method, outside that method?
body: <p>I am using VS 2008 (C#)... I have created a function in a GlobalClass to use it globally.. This is for opening a dialog box. When I call this function in my method it works but I am not able to use the Object "OFD" that I have created here...</p>
  
  <pre><code>static class GlobalClass
  {
   public static void OFDbutton()
    {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Filter = "Image files|*.jpg;*.jpeg;*.png;*.gif";
     DialogResult dr = ofd.ShowDialog();
    }
  }
  </code></pre>
  
  <p>In the form method. I am using </p>
  
  <pre><code>globalclass.ofdbutton(); //Calling the function
  lable1.text=ofd.filename;
  </code></pre>
  
  <p>I want to use object "ofd" but I am unable to do so.. What I have to do about this, please help</p>