Why can I not use a "constant" within a switch statement within scope?

Posted by Clay Shannon on Stack Overflow See other posts from Stack Overflow or by Clay Shannon
Published on 2012-03-22T23:04:33Z Indexed on 2012/03/22 23:30 UTC
Read the original article Hit count: 192

Filed under:
|
|

With this code:

public partial class Form1 : Form
{
    private static readonly int TABCONTROL_BASICINFO = 0;
    private static readonly int TABCONTROL_CONFIDENTIALINFO = 1;
    private static readonly int TABCONTROL_ROLESANDSECURITY = 2;
    private static readonly int TABCONTROL_INACTIVEINFO = 3;
. . .
int ActiveTabPage = tabControlWorker.SelectedIndex;
switch (ActiveTabPage) {
    case TABCONTROL_BASICINFO:
        if (currentNode == "NodeBuckingham") {
        } else if (currentNode == "NodeNamath") {
        } else if (currentNode == "NodeParsons") {
        } else {
        }
    break;

...I have to replace "TABCONTROL_BASICINFO" with "0", or I get, "A constant value is expected"

Heavens to Murgatroyd! Can't it look up and see that TABCONTROL_BASICINFO is 0?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET