5

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

public enum SubPackageBackupModes
{
    Required,
    NotRequired //no comma
}

public enum SubPackageBackupModes
{
    Required,
    NotRequired, //extra unnecessary comma 
}

Since both compile, is there any differences between these declarations?

Community
  • 1
  • 1

2 Answers2

4

I prefer second syntax because if you will add addition member to your enum you will have only one line difference in SCM.

Snowbear
  • 16,661
  • 3
  • 41
  • 66
  • You can also achieve that by putting the comma before the value (i.e. no comma on the first line) -- ugly but can be useful for cases where the extra comma isn't allowed. – tgdavies Feb 26 '11 at 11:01
  • 4
    @tdavies, agree, ugly :) I will prefer having two lines of diff instead of lines starting with comma. – Snowbear Feb 26 '11 at 11:03
2

No, there is no difference.

This was allowed in C++ also, and that continues. I guess it is easier with the comma, since you may comment out the last enum element and it is easier for code-generation tools.

Cody Gray
  • 230,875
  • 49
  • 477
  • 553
Ken D
  • 5,740
  • 1
  • 33
  • 58