我是新来C#我真的需要知道如何调用/使用另一种方法的字符串。
例如:C#引用一个变量从另一种方法
public void button1_Click(object sender, EventArgs e)
{
string a = "help";
}
public void button2_Click(object sender, EventArgs e)
{
//this is where I need to call the string "a" value from button1_click
string b = "I need ";
string c = b + a;
}
因此,在这个例子中,我需要从函数调用字符串“一个”在功能上button1_Click()
定义button2_Click()
谢谢!
这样一个坏实践。为了完成小型工作,不建议使用这种方法。 – 2017-05-04 09:40:47