c#为.show()和.hide()创建对象

112*_*58d 0 .net c# class object visual-studio

有没有办法在C#中创建这样的方法:

public void showHide(string shOne, string shTwo, string shThree) {
     button1.shOne();
     button2.shTwo();
     button3.shThree();
}

private void discountButton_Click(object sender, EventArgs e) {
    showHide("Show", "Hide", "Hide")
    // I was thinking that this should be the same as
    // button1.Show();
    // button2.Hide();
    // button3.Hide();
}
Run Code Online (Sandbox Code Playgroud)

这可能吗 ?我正在为论文设计ac#应用程序,我需要显示和隐藏按钮(许多按钮和标签和东西).

我现在使用此代码,但我一直收到错误:

Panel'不包含'shOne'的定义.

nma*_*ait 7

public void showHide(bool shOne, bool shTwo, bool shThree) 
{
     button1.Visible = shOne;
     button2.Visible = shTwo;
     button3.Visible = shThree;
}
Run Code Online (Sandbox Code Playgroud)