怎么传递字符串。。。。急!!!
怎么把info里面的 a 传到 button1里面,代码如下:public partial class info : Form
{
public info()
{
InitializeComponent();
string a="guo";
}
private void button1_Click(object sender, EventArgs e)
{
string b=a;
} --------------------编程问答--------------------
--------------------编程问答-------------------- 顶起。。。。。。。 --------------------编程问答-------------------- public string a="guo";
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);
}
}
private void button1_Click(object sender, EventArgs e)
{
string b=a;
} --------------------编程问答-------------------- button1.text = a; --------------------编程问答--------------------
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);
}
}
对,用全局变量 --------------------编程问答-------------------- 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;
} --------------------编程问答-------------------- 路过,学习。 --------------------编程问答-------------------- --------------------编程问答-------------------- 一楼的值得一看 --------------------编程问答-------------------- 这个难 顶一下 --------------------编程问答-------------------- 汗,变量的使用范围还没搞明白 --------------------编程问答-------------------- --------------------编程问答-------------------- 谢谢大家啦
补充:.NET技术 , C#