开发者

Unnecessary comma in enum declaration [duplicate]

开发者 https://www.devze.com 2023-02-13 19:14 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: .NET Enumeration allows com开发者_JAVA技巧ma in the last field
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

.NET Enumeration allows com开发者_JAVA技巧ma 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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消