Yes you can, using
this.pictureBox1
object, since you are assigning the values of h and w to the picture box in the button1 click event.
private void button2_Click(object sender, EventArgs e)
{
int h = pictureBox1.Height;
int w = pictureBox1.Width;
MessageBox.Show("Height is- " + h + " Width is- " + w, "Height & Width");
}