Take the 2-minute tour ×

When breaking out classes into files, I am wondering what the naming convention is for class files containing only enums. Should they match the enum name, like any other class, or should they be suffixed with 'Enum' so that the developer knows that the file contains only an enum?

For example:

namespace MyCompanyName.MyApplication
    public enum Colors

Would you say the file containing the above code should be named 'Colors.cs' or 'ColorsEnum.cs'? Alternatively, perhaps there is another accepted naming convention for such files?

share|improve this question
No. You picked the worst possible example, nobody will understand why Colors.Orange isn't valid. Calling it ColorsEnum does not help. But that all gets sorted out by IntelliSense. You may assume it is used. –  Hans Passant Jun 22 '11 at 0:36
add comment

4 Answers

up vote 3 down vote accepted

First off, this is a complete personal/team preference thing.

That being said:

I personally would name it Colors.cs. This keeps the filename corresponding to the type name. When I'm working on the API, if "Colors" are a fixed set of things represented by an enum, I'd probably know that, and there would be no confusion.

share|improve this answer
add comment

What about creating a folder called Enums and naming the file Colors.cs?

share|improve this answer
I agree with this. If a file only contains a single object declaration I find it useful that the filename be the same as the object. –  Derrick Jul 22 '11 at 21:51
add comment

The file name in my opinion should be the same as the name of the Enum, which - according to the Enum Naming guidelines should not have an Enum suffix. Also the guideline suggests your enum should be singular so taking both into account it should be Color.cs

share|improve this answer
add comment

Creating a folder called Enumerations, Enums or something descriptive should be enough. Also you can follow the C# naming standards that said:

"Names of Enumerations Do not use a prefix on enumeration value names. For example, do not use a prefix such as ad for ADO enumerations, or rtf for rich text enumerations, and so on.

This also implies that you should not include the enumeration type name in the enumeration value names. The following code example demonstrates incorrectly naming an enumeration's values.

C# code as follows

public  enum Teams

References: Names of Classes, Structs, and Interfaces

share|improve this answer
I am aware that the type name should not contain a prefix or suffix, but this question is specifically asking in reference to the filename. –  Luke Baulch Jun 22 '11 at 0:09
You can't just copy someone else's content and redistribute it like this, that's what “Copyright X, all rights reserved” means. By posting on Stack Exchange, you declare that you have the right to distribute the post content under a CC BY-SA license. Please write an answer in your own words (and possibly link to an external site for more information). –  Gilles Jun 22 '11 at 11:36
add comment

Your Answer


