Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple options for Enum values

Status
Not open for further replies.

BenSC

Technical User
Jul 24, 2001
43
GB
Dear All,
I've been tasked with updating an Enumeration in a vb.net 2003 solution. The existing enum looks as follows

A = 48
B = 49

However, the requirement is now that each item can result from multiple values. For example:

A = 48 or 65 or 66
B = 49 or 67

I have tried amending the enum as above, but it doesn't evaluate correctly and returns nothing.

I am not free to dictate the numbers selected on as they're bound to table values.

Does anyone know if it is actually possible to do this with an enumeration, or am I going to have to re-write the logic for this task?

Any help would be much appreciated.
Regards
Ben Cooper
 
No you can't do that. Yes you are going to have to rewrite your logic, and that's going to depend on exactly what you are doing. The information I am getting is that you are bringing in numerical values from a database. Then what happens? How is your current code using the enums?
 
Like RiverGuy says -- you can't do that.

An enum is a mapping from a name to a value, with the underlying assumption that the name is unique.

You can do the reverse (multiple names mapping to the same value), but not a single name mapping to multiple values.

AFAIK, you can't even do it with static/shared constants. The name must be unique.

Chip H.


____________________________________________________________________
www.chipholland.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top