public partial class info : Form
{    public info()
{
InitializeComponent();
a = "guo";
}
private string a = "";
private void button1_Click(object sender, EventArgs e)
{   
string b=a;
MessageBox.Show(b);
}
}

解决方案 »

  1.   

    public string a="guo";private void button1_Click(object sender, EventArgs e)
      {   
      string b=a;
      }
      

  2.   

    public partial class info : Form
    {       public info()
        {
            InitializeComponent();
            button1.Tag = "guo";
        }    private void button1_Click(object sender, EventArgs e)
        {   
            string b=button1.Tag.ToString();
            MessageBox.Show(b);
        }
    }
      

  3.   

    string a应设为类变量:public partial class info : Form
      {   
      string a=null;
      public info()
      {
        
      InitializeComponent();
      string a="guo";
      }
     private void button1_Click(object sender, EventArgs e)
      {   
      string b=a;
      }