当我尝试从不同的按钮访问bool变量时,如下所示:
private void button1_Click(object sender, EventArgs e)
{
//Those my bool variable I want to access from the second button
bool second = false , third = false , forth = false , fifth = false;
}
private void button4_Click(object sender, EventArgs e)
{
//Here is where I try to access, but i can't.
second = true;
}
谢谢。
答案 0 :(得分:0)
您只需将它们设置为全局变量即可。
bool second, third , forth , fifth = false;
private void button1_Click(object sender, EventArgs e)
{
//Those my bool variable I want to access from the second button
second = false;
third = false;
forth = false;
fifth = false;
}
private void button4_Click(object sender, EventArgs e)
{
second = true;
}