471,336 Members | 1,294 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How do you generate new enumerations at runtime?

Okay, so the deal is, I'm using the enum structure to populate some list, the
problem is that I don't have the enums at compile time, they must be
generated at runtime (i.e. read from some file or what not). I need them to
be in the enum type of structure for a specific control that I've built (and
don't want to rebuild in some other manner). Is there a way to generate an
enum at runtime or am I stuck making a class that acts like the enum?

Nov 29 '05 #1
3 1296
> Okay, so the deal is, I'm using the enum structure to populate some
list, the problem is that I don't have the enums at compile time, they
must be generated at runtime (i.e. read from some file or what not).
I need them to be in the enum type of structure for a specific control
that I've built (and don't want to rebuild in some other manner). Is
there a way to generate an enum at runtime or am I stuck making a
class that acts like the enum?


You could try your hand at using EnumBuilder. I've never had luck making
it work. You may be different.

I would stick to a class. They are more flexible in the long run.
Nov 29 '05 #2
Jebrew wrote:
Okay, so the deal is, I'm using the enum structure to populate some list, the
problem is that I don't have the enums at compile time, they must be
generated at runtime (i.e. read from some file or what not). I need them to
be in the enum type of structure for a specific control that I've built (and
don't want to rebuild in some other manner). Is there a way to generate an
enum at runtime or am I stuck making a class that acts like the enum?


Enums are supposed to be used to build type-safe code. If you haven't
got the need for that (ie. you're doing this at runtime instead of
compile time), why not just stick to a list of strings?

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Nov 30 '05 #3
Hi,

In this escenario I would go for a class , enum (as some other poster said)
are intented to clarify your code (like avoiding using numbers) .
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jebrew" <Je****@discussions.microsoft.com> wrote in message
news:3C**********************************@microsof t.com...
Okay, so the deal is, I'm using the enum structure to populate some list,
the
problem is that I don't have the enums at compile time, they must be
generated at runtime (i.e. read from some file or what not). I need them
to
be in the enum type of structure for a specific control that I've built
(and
don't want to rebuild in some other manner). Is there a way to generate
an
enum at runtime or am I stuck making a class that acts like the enum?

Nov 30 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Plinkerton | last post: by
1 post views Thread by someone else | last post: by
1 post views Thread by Oleg Ogurok | last post: by
4 posts views Thread by ChrisB | last post: by
4 posts views Thread by John Hom | last post: by
38 posts views Thread by One Handed Man \( OHM - Terry Burns \) | last post: by
77 posts views Thread by Ben Finney | last post: by
11 posts views Thread by Girish Sahani | last post: by
reply views Thread by rosydwin | last post: by

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.