C# FAQ: Can const and static be used together

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:FAQs
edit

Can const and static be used together?

No. The C# specification states that the inclusion of the static modifier is redundant and prohibited; because, constant declarations are implicitly static. Allowing both could cause confusion when one declaration includes the modifier but another does not. However, there is no prohibition against specifying an access modifier which is also the default. Perhaps the intention is to permit redundant modifiers when there is a choice but to deny them when there is no choice.

See also


Personal tools