Vlado Pandžić
Vlado Pandžić

Reputation: 5058

Best practise to put enums in mvc app?

I have MVC app with really lot of enumerations. What would be the best practise for organizing enumeration inside MVC project. Inside model class, create separate class for enums, ...?

Upvotes: 1

Views: 1177

Answers (1)

to StackOverflow
to StackOverflow

Reputation: 124756

MVC isn't really any different from any other .NET technology in this respect.

In general, there's no need to nest enums inside a class - just put them into a suitable namespace that's related to their purpose. If the purpose is limited to one or a few classes, put it in the same namespace and project as these classes.

If an enum is only ever used by a single class, you could nest the enum type in the class, but there's little benefit.

Upvotes: 1

Related Questions