473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

can I create an enum dynamically in the code?

Can I create an enum dynamically in the code, e.g. data base driven?

Thanks!
Ryan
Apr 4 '06 #1
4 8995
Would it be better to just use integer or char instead?

Afterall, the enum's effective value would be something of the sort.

"Ryan Liu" <ad********@online.sh.cn> ¼¶¼g©ó¶l¥ó·s»D:OJ**************@TK2MSFTNGP14.phx.g bl...
Can I create an enum dynamically in the code, e.g. data base driven?

Thanks!
Ryan

Apr 4 '06 #2
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
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ryan Liu" <ad********@online.sh.cn> wrote in message
news:OJ**************@TK2MSFTNGP14.phx.gbl...
Can I create an enum dynamically in the code, e.g. data base driven?

Thanks!
Ryan

Apr 4 '06 #3
On Tue, 04 Apr 2006 16:21:53 +0800, Ryan Liu Woke up an had these words of
wisdom to grace the world.:
Can I create an enum dynamically in the code, e.g. data base driven?

Thanks!
Ryan


How about EnumBuilder in system.Reflection.Emit ?

Apr 9 '06 #4
Can I create an enum dynamically in the code ...


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
Jun 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Dev | last post by:
Dear Friends, Is it possible to add the Enum in dynamically. Like Ex: enum Colors { Green, Red,Yellow,Blue,Orange } So i want add 6th name Black to Colors.Is it possible? If so how?...If...
5
by: Ken Allen | last post by:
I have a need to convert the names of the members of an enumeration into an array of strings at runtime. I have determined a method using reflection. Type theType = typeof(MyEnumName);...
15
by: apm | last post by:
Can an enum start empty and be added to on the fly?
7
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al =...
1
by: Sudhakara.T.P. | last post by:
Hi, I want to populate my Enum dynamically from the database. Is that possible? If so, what is the approach that I need to take. I need this because I have some set of constants in my table...
6
by: Zytan | last post by:
I have an enum. I want a struct of data associated with each one. Then, I could use the enum to access the data as needed. In other words, I want the enum to represent more than just a unique...
3
by: John Wright | last post by:
I have an enum based on a lookup table in my database. However, when a new item is added to the lookup table or one is removed, I have to modify the enum to match. Is there a way to dynamically...
7
by: Rob | last post by:
This actually compiles and works but it doesn't seem like the best code, so I was wondering is there another way to do this? template <typename Tvector<T>* addDepth(T) { return new vector<T>;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.