Enum and property naming conflicts

后端 未结 2 2019
南笙
南笙 2020-12-08 13:34

When using a class that has an enum property, one usually gets a naming conflict between the property name and the enum type. Example:

enum Day{ Monday, Tues         


        
2条回答
  •  遥遥无期
    2020-12-08 14:03

    There is no conflict. In fact, the .NET Framework style guide encourages you to do this, e.g. if you have a class that has a single property of a type (no matter if enum or class), then you should name it the same. Typical example is a Color property of type Color. It's fine, unless there are two colors - in that case both should add something to the name (i.e. BackColor and ForeColor, instead of Color and BackColor).

提交回复
热议问题