C# naming convention for enum and matching property

前端 未结 8 1100
鱼传尺愫
鱼传尺愫 2020-12-02 07:03

I often find myself implementing a class maintaining some kind of own status property as an enum: I have a Status enum and ONE Status property of Status type. How should I s

8条回答
  •  鱼传尺愫
    2020-12-02 07:32

    I suggest adding "Option" to the type name (or Flag if it contains bit flags), i.e. type is Car.StatusOption and property is Car.Status.

    Compared to pluralizing, this avoids naming collisions when creating collections of the enum type, where you would normally want to pluralize the collection property, not the enum type.

提交回复
热议问题