Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the naming convention for ENUMs in C# usually have everything in UPPERCASE?

Tags:

Here's my ENUM:

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

I realize there are no strict conventions but normally would the files Two,Three and Five be in uppercase?

like image 741
Alan2 Avatar asked Dec 10 '17 04:12

Alan2


People also ask

How should enums be named?

Enums are types, so they should be named using UpperCamelCase like classes. The enum values are constants, so they should be named using lowerCamelCase like constants, or ALL_CAPS if your code uses that legacy naming style.

Does C use camelCase or Snakecase?

Classic C doesn't use camel-case; I've written code in camel-case in C, and it looks weird (so I don't do it like that any more). That said, it isn't wrong - and consistency is more important than which convention is used.

Should enum be capitalized in C?

Function, typedef, and variable names, as well as struct, union, and enum tag names should be in lower case.

Are enum names plural or singular?

Enums in Java (and probably enums in general) should be singular.


1 Answers

One should use Pascal case when they are typing enum types and values. This 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 that you should make all caps like that are constant/final variables.

When you have local variables you should always use camel case.

thisIsCamelCasedVariable = "ya baby"; 

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

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

like image 145
Jamin Avatar answered Sep 27 '22 17:09

Jamin