Search code examples
c#voidgoto

How to go from one "private void" to other "private void"?


how can i go from private void turnon to private void turnoff ? I want only know how to go from one void to other. I know i can just make from these two a one private void but i don't want it

private void turnon(object sender, EventArgs e)
{
    button2.Visible = true
}

private void turnoff(object sender, EventArgs e)
{
    button3.Visible = false
}

Solution

  • If you're wanting it to be visible in one event and visible in another, why not use one method like so:

    private void SwitchState(object sender, EventArgs e)
    {
        button3.Visible = !button3.Visible;
    }
    

    On reading your comments I guess you want to add this line in at the end of your turnon event:

    turnoff(sender, e);