#318 – You Can’t Use the static Modifier On a Constant

Although constants can be treated as static member variables, you cannot include the static keyword when declaring a constant.  A constant is always effectively static, so the static keyword would be redundant.  The compiler will generate an error if you include it.

        // This is ok
        const string Demeanor = "friendly";

        // !! Compiler error - constant cannot be marked static
        static const int TheAnswer = 42;
Advertisement