473,472 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Enumerations

Greetings,

I was wondering if there was a way of dynamically
creating enumerations. For example, we could do it
statically like:

enum stuff
zero,
one,
two,
three
end enum

But what if we later discover we need to add "four" to
stuff?

There are two methods, Enum.Parse(), that take a comma-
delimited string, but I don't think this is what I want.

Any help would be greatly appreciated!

Happy Holidays to all!

John
Nov 20 '05 #1
4 989
> I was wondering if there was a way of dynamically
creating enumerations. (...)


Well...
There is, but it's not worth the effort.

For example you could create the list in the runtime, then create a source
module (*.vb) dynamically that contains your enum, _then_ call the VB.NET
compiler, and _then_ late-bind to the resulting assembly.
Whoa...

--
sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation
Nov 20 '05 #2
* "John Hom" <jh**@dcas.nyc.gov> scripsit:
I was wondering if there was a way of dynamically
creating enumerations. For example, we could do it
statically like:

enum stuff
zero,
one,
two,
three
end enum

But what if we later discover we need to add "four" to
stuff?


Add it in the code... What's the problem? Why do you need to "add" it
at runtime? Maybe you are looking for a collection, not for an
enumeration.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
> There are two methods, Enum.Parse(), that take a comma-
delimited string, but I don't think this is what I want.


Read http://msdn.microsoft.com/msdnmag/is...t/default.aspx about
Parse() method

sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation
Nov 20 '05 #4
Well, if you ignore the nasty version problems that will happen if you go
this route, you can use System.Reflection.Emit to create types dynamically
at runtime.
However, since Enums are mostly a convention of convenience for the
PROGRAMMER working with code, it doesn't really do much good to add more at
runtime, does it?

-Rob Teixeira [MVP]

"John Hom" <jh**@dcas.nyc.gov> wrote in message
news:15*****************************@phx.gbl...
Greetings,

I was wondering if there was a way of dynamically
creating enumerations. For example, we could do it
statically like:

enum stuff
zero,
one,
two,
three
end enum

But what if we later discover we need to add "four" to
stuff?

There are two methods, Enum.Parse(), that take a comma-
delimited string, but I don't think this is what I want.

Any help would be greatly appreciated!

Happy Holidays to all!

John

Nov 20 '05 #5

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

Similar topics

1
by: Joyce | last post by:
In my schema I have 2 enumerations, let's say, country description and country code, and I want to use them so I can map each country description to its precise country code (and no other). So far...
0
by: Plinkerton | last post by:
I'm making an Base Class that will be inherited. In my base class, I have a public enumeration that defines a list of things I want my class to be able to do. I use it for Method input...
21
by: Christopher Benson-Manica | last post by:
I'll try to explain what I want to do: I have foo.h and foo.cpp. Units that include foo.h will define an enumeration bar: enum bar { typeNone, typeBaz, typeQuux, ... , count }; A method...
3
by: JoeH | last post by:
Hi, I'm using a COM DLL (created in VB) in my javascript code and can successfully call its methods and get/set its properties. There are also some Public enumerations defined in the ActiveX...
5
by: Seamus M | last post by:
I can't find any info on enumerations in the PHP manual, so I assume there is no built in way to create them. Can anyone tell me the best way to build a simple enumeration, such as: Enum...
1
by: someone else | last post by:
I have some code that creates dynamic enumerations for use in a PropertyGrid control. This all works perfectly but the memory usage of the program increases quite quicly when viewing the...
1
by: Oleg Ogurok | last post by:
Hi all, I've added a new DataSet (xsd file) to my project in VS.NET 2003. There I create a simple type as an enumeration of values. <xs:simpleType name="MyCustomType"> <xs:restriction...
4
by: ChrisB | last post by:
Hello: I will be creating 50+ enumerations related to a large number of classes that span a number of namespaces. I was wondering if there are any "best practices" when defining enumerations. ...
27
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to...
77
by: Ben Finney | last post by:
Howdy all, PEP 354: Enumerations in Python has been accepted as a draft PEP. The current version can be viewed online: <URL:http://www.python.org/peps/pep-0354.html> Here is the...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.