R Ryan Liu Apr 4, 2006 #1 Can I create an enum dynamically in the code, e.g. data base driven? Thanks! Ryan
L Lau Lei Cheong Apr 4, 2006 #2 Would it be better to just use integer or char instead? Afterall, the enum's effective value would be something of the sort.
Would it be better to just use integer or char instead? Afterall, the enum's effective value would be something of the sort.
I Ignacio Machin \( .NET/ C# MVP \) Apr 4, 2006 #3 Hi, And use it how? the only reason of the enum is to gives meanful names to values, just use the values from the DB
Hi, And use it how? the only reason of the enum is to gives meanful names to values, just use the values from the DB
J Jerry Walter Apr 9, 2006 #4 Can I create an enum dynamically in the code, e.g. data base driven? Thanks! Ryan Click to expand... How about EnumBuilder in system.Reflection.Emit ?
Can I create an enum dynamically in the code, e.g. data base driven? Thanks! Ryan Click to expand... How about EnumBuilder in system.Reflection.Emit ?
G Guest Jun 17, 2006 #5 Can I create an enum dynamically in the code ... Click to expand... enum My_enm : int { First_value, Second_value } int l_enm_val = 7; Enum l_new_enm_ins; Type l_enm_typ; Object l_enm_obj l_enm_typ = typeof( My_enm ); l_new_enm_ins = ( Enum ) Activator.CreateInstance(l_enm_typ); l_new_enu_ins = ( Enum ) Activator.CreateInstance(l_enm_typ, l_num_value ); l_enm_obj = ( My_enm ) Enum.ToObject( l_enm_typ, l_enm_val ); Hope this helps. Shawnk
Can I create an enum dynamically in the code ... Click to expand... enum My_enm : int { First_value, Second_value } int l_enm_val = 7; Enum l_new_enm_ins; Type l_enm_typ; Object l_enm_obj l_enm_typ = typeof( My_enm ); l_new_enm_ins = ( Enum ) Activator.CreateInstance(l_enm_typ); l_new_enu_ins = ( Enum ) Activator.CreateInstance(l_enm_typ, l_num_value ); l_enm_obj = ( My_enm ) Enum.ToObject( l_enm_typ, l_enm_val ); Hope this helps. Shawnk