PDA

View Full Version : Problems with enums


christrinder
09-13-2007, 12:37 PM
Hi all. I'm having problems with enums. I thought I understood how to use them, but clearly I don't! I want to use them to refer to corresponding ID's in a database within the code (to make it more readable). So I set-up:

public enum ItemStatus
{
Incomplete = 1,
PendingApproval = 2,
Rejected = 3,
Approved = 4,
}

...it all looked good in the code, but I'm getting some odd results when I use the application. I've read in different places that;
- I might need a zero value
- they need to be alphabetically ordered
- they need to increment in powers of 2

... none of which fit easilly with my database. Is there a better way to do this?

nikkiH
09-13-2007, 02:15 PM
None of those things are true.
What specific problem are you having? I use enums just like that with no issues other than a conversion between the int and the enum. It doesn't do it for you.