Singular or plural for enumerations?
Do you use singular or plural for enumerations? I think it makes best sense with plural in the declaration
enum Weekdays
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
... but I think it makes more sense with singular when using the type, e.g.
Weekday firstDayOfWeek = Weekday.Monday;
I read a recommendation somewhere to use singular whith regular enums and plural with flags, but I would like to hear some more pros and cons.
Here it is straight from Microsoft:
http://msdn.microsoft.com/en-us/library/4x252001(VS.71).aspx
Use a singular name for most Enum types, but use a plural name for Enum types that are bit fields.
One recommendation comes from the .NET Framework Design Guidelines, page 59-60:
Do use a singular type name for an enumeration, unless its values are bit fields.
public enum ConsoleColor { Black, Blue, Cyan, ...
Do use a plural type name for an enumeration with bit fields as values, also called a flags enum.
[Flags] public enum ConsoleModifiers { Alt, Control, Shift }
In the .NET Framework, most "normal" enums (e.g. DayOfWeek
) have singular names and flag enums (e.g. StringSplitOptions
, BindingFlags
) have plural names. It makes sense, since a value of a flag enum can represent multiple items but for a non-flag enum, it can only represent a single item.