Is there a naming convention for ENUM in C #, usually in UPPERCASE?

Here is my ENUM:

public enum ATI
{
    Two = 0,
    Three = 1,
    Five = 2,
}

I understand that there are no strict conventions, but usually the files Two, Three and Five will be in uppercase?

+4
source share
2 answers

The Pascal case should be used when they print the types and values โ€‹โ€‹of an enumeration. It looks like

public enum Ati
{
    Two = 0,
    Three = 1,
    Five = 2,
}

According to Microsoft:

   Identifier      |   Case    |   Example
--------------------------------------------
Enumeration type   |  Pascal   |  ErrorLevel      
Enumeration values |  Pascal   |  FatalError

The only thing you should do is constant / final variables.

If you have local variables, you should always use the camel case.

thisIsCamelCasedVariable = "ya baby";

More about transfers: https://msdn.microsoft.com/en-us/library/4x252001(v=vs.71).aspx

More on C # naming conventions: https://msdn.microsoft.com/en-us/library/ms229043%28v=vs.100%29.aspx

+7

Jamins answer:
# PascalCasing

"" , , , , :

public enum SeasonOfTheYear
{
    Spring = 0,
    Summer = 1,
    Autumn = 2,
    Winter = 3
}

" ", , . , :

[Flags]
public enum FilePermissions
{
    None = 0,
    X = 1,
    W = 2,
    R = 4
}

.NET Design-Guidelines - , :

( ) (PascalCasing ..). , .

โœ“ , .

โœ“ , .

X "Enum" .

X "" "" .

X (, "" ADO, "rtf" ..).


:
. . "" # Reference enum. .
, . , , .

+1

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


All Articles