How can I use web.config value in switch case in C# without if , else loop "A constant value is expected."
<p>Below is switch case </p>

<pre><code>switch (strID)
{
    case ConfigurationManager.AppSettings["Key1"].ToString():
        Label1.Visible = true;
        break;
    case ConfigurationManager.AppSettings["Key2"].ToString():
        Label2.Visible = true;
        break;
    case ConfigurationManager.AppSettings["Key3"].ToString():
        Label3.Visible = true;
        break;
    default:
        Label1.Visible = true;
        break;
}
</code></pre>

<p>But it gives error <strong>"A constant value is expected."</strong></p>

<p>I know that you can't have variables in the switch statement.But is any way ?</p>