0

Possible Duplicate:
.NET Enumeration allows comma in the last field

i noticed while i was refreshing my memory on c# that with enums, you dont get a complaint from the compiler when you leave a comma after the last variable... EG

enum fruit {
    apple,
    pear,
    watermelon,
}

i was wondering you can do this? shouldnt the compiler say "syntax error: ," or something?

Community
  • 1
  • 1
Rhexis
  • 2,414
  • 4
  • 28
  • 40
  • It looks useful to me if there's a possibility you'll be adding more stuff later. This permits the same syntax on every item. – Loren Pechtel Aug 09 '11 at 02:24

1 Answers1

0

It is part of the C# specification, the compiler is simply following it.

Document: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf Page 363, Section 19.7

foxy
  • 7,599
  • 2
  • 30
  • 34