Was surprised to see that a C# Enum definition seems to allow an extra comma at the end (at least in VS2010).
e.g. :
public enum EnumTest1
{
Abc,
Def,
}
i.e. there is a comma at the end of “Def”.
Just wondering if this is allowed by design, or is an oversight.
(This might be good to know, because if it is a bug, there may be no guarantees that code like the above will compile in future versions of C#).
It is allowed by design. Similarly, you can have trailing commas in initializers as well. For example:
I think that allowing trailing commas makes creating auto-generated code much easier because you don’t have to add last-in-the-list logic when outputting a list in your code.