« Return to Thread: Easy way to handle enum

Re: Easy way to handle enum

by Marco Franssen :: Rate this Message:

Reply to Author | View in Thread

Why don't you just use integer or byte for saving the enum. If you have less then 255 enum values you use a byte for saving the integer.

public Enum MyEnum
{
       Value1 = 0,
       Value2 = 1,
       Value3 = 2,
       Value4 = 3,
       Value5 = 4
}

You can just cast then your byte values like this

byte enumvalue = Query.Database();
MyEnum currentvalue = (MyEnum) enumvalue;

2009/6/25 tech fan <monstercorp@...>
Hi, I'm new to Ibatis.net and want to know if there is easy way to handle enum types.
I have enums stored in db as string, and sometimes I just want a list of the enum  returned: IList<enumtype>, but I can not find a way to handle this map. Any anoying thing is, when I pass enum as parameter, unless I use a parameterclass, it seems I have no way to turn them into string. Any idea?
 
Regards,
T.C.



--
Met vriendelijke groet,

Marco Franssen

 « Return to Thread: Easy way to handle enum