Using static in an enumeration

Is it possible to use "static" in an enumeration as such:

private enum pdfMode { generate, static } 

Obviously, “static” is a keyword.

It would be nice, since I have pdfMode, which is really referred to as "static" in the application.

+4
source share
4 answers

One possibility is to use Generate and Static inside an enumeration. In any case, IMO in uppercase looks best.

+6
source

To use the keyword as an identifier, use the @ symbol:

 @static 

But the use of Pascal is advisable here.

 private enum PdfMode { Generate, Static } 

See Enumeration Type Naming Principles :

Use the Pascal argument for names and name names.

+18
source

You can escape the keyword using @ , for example:

 private enum pdfMode { generate, @static } 
+6
source
 private enum PdfMode { PdfMode_Generate, PdfMode_Static } 

since it does not conflict with

 private enum xxxType { xxxType_Moving, xxxType_Static } 
-2
source

Source: https://habr.com/ru/post/1335107/


All Articles