Naming convention question
So for context, for educational purposes (and only to learn), I'm trying to reconstruct the box packing system from my job. Now, I have a enum that contains all the different types of boxes, its called BoxType, and its inside of the Shipment (aka box) class. I want to have a BoxType property, and I feel like "BoxType" is also a good name for the property name, but as you could imagine, it says I'm not allowed to do this as the enum is already called "BoxType". And i thought "maybe lets put the b as lowercase", and now it gives me a warning that there's a naming convention issue, and that it should start with a B. Now I know this doesn't matter, but I'm trying to learn best practices for the future. What's the right way to do this?
I might suck at explaining stuff, but here's what I mean.
9 Replies
now that I'm thinking more clearly, maybe the BoxType enum should be BoxTypes?
No
Naming convention for enums is singular
Names of Classes, Structs, and Interfaces - Framework Design Guidel...
Use these guidelines for naming Classes, Structs, and Interfaces as part of guidelines for designing libraries that extend and interact .NET libraries.
I actually think your example is fine. What says it's not allowed?
It should really be a property not a field but I think the name should be ok?
The type "Shipment" already contains a definition for "BoxType"
Oh. Move the enum declaration outside of the class definition
I didn't notice it was nested
Should enums not be nested in classes?
Not usually, no
okay, hehe im still new to this tbh. thank you for the help :)