How to fix the switch method

1347 views c#
7

// This is the problem I am getting when I want to detect if it opens, then it injects a dll into that program, if else then it will stay undefined.

public partial class Form1 : Form
{

    public Form1()
    {
        InitializeComponent();
    }

    private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {

        bool start = Process.GetProcessesByName("Calculator").Length == 1;

        if (checkBox1.Checked)
        {
            switch (start)
            {
                case start:

                    break;
            }
        }
    }
}

}

answered question

I wouldn't bother with a switch statement on a bool value. Just use an if (start) { ... } but you're probably trying to figure out why your switch isn't working. case start: should be case true:

Thanks for the help Adam!

1 Answer

10

why do you use switch for a Boolean value?

posted this

Have an answer?

JD

Please login first before posting an answer.