I was looking for some enums options, and just spotted a missing comma after last option. Take, for instance, that DayOfWeek enum (press F12 to go to definition):
public enum DayOfWeek
{
Sunday = 0,
Monday = 1,
Tuesday = 2,
Wednesday = 3,
Thursday = 4,
Friday = 5,
Saturday = 6, // note this comma
}
Are there any reason behind this behavior?
The trailing comma after the last
enummember is optional. This was presumably done to aid automatic code generation which can just spit out stuff without thinking about the grammar.Whether the comma is present or not doesn’t change anything.
Take a look at the grammar:
As you see, the enum-body includes the option of a single trailing comma.