Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to put Enumerations
Message
From
06/03/2006 16:26:50
 
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
01101840
Message ID:
01101858
Views:
16
This message has been marked as the solution to the initial question of the thread.
Chad,

This is always my favorite answer .... it depends! <g>

Seriously, though, I think it does depend. If the enum is only used in that class, then I'd put it in the class. If it's something that will be used elsewhere, then put it outside the class.

There are always "exceptions to the rule" ... I have a few projects in my app where I have a separate enumerations.cs file containing all the enums for a particular namespace. If I had a class in one of those namespaces and it needed an enum that would only be used in that class, in this particular case I'd probably put it in the enumerations.cs file instead of within the class itself ... simply for the consistency of having all the enums in one file.


~~Bonnie




>Hi all,
>
>Is it better to put an enumeration within the class definition or outside of the class, but within the namespace? And why?
>
>TIA,
>Chad
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform