How To use variable values from one method to another method in c#? : I have a GUI functioning code, in which I am using two 'button' methods. I want to use values of some variables from first method to another. like- I want to use values of h and w of button1_Click in button2_Click. How is it possible ??

    public int h, w;
    public Form1()
    {
        InitializeComponent();

        textBox1.Text = "Image Path here ...";

    }

    public void button1_Click(object sender, EventArgs e)
    {
        OpenFileDialog dlg = new OpenFileDialog();
        dlg.Title = "Select an Image";
        dlg.Filter = "jpg files (*.jpg)|*.jpg";
        if (DialogResult.OK == dlg.ShowDialog())
        {
            this.pictureBox1.Image = new Bitmap(dlg.FileName);
            Bitmap img = new Bitmap(dlg.FileName);
            int w = img.Width;
            int h = img.Height;
            pictureBox1.Height = h;
            pictureBox1.Width = w;
            textBox1.Text = dlg.FileName;

        }

    }

    public void button2_Click(object sender, EventArgs e)
    {

        MessageBox.Show("Height is- " + h.ToString() + " Width is- " + w.ToString(), "Height & Width");
    }
  }
}