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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying an enum

Status
Not open for further replies.

jmcpher

Programmer
Jun 4, 2001
84
US
Does anyone know if there is an easy way to copy an enum? I know [ok, think] I could do something like:

enum MyEnum {
One = TheirEnum.One,
Two = TheirEnum.Two,
Three = TheirEnum.Three,
...
}

but I am wondering if a better way exists?

"Programming is like sex, one mistake and you have to support it forever."

John

johnmc@mvmills.com
 
I kind of doubtful that you can do this - the values in an enum have to be resolved at compile time, and while you're setting them to another enum (also resolved at compile time), it just seems like you're asking for trouble by doing this. I would just create another enum whose values correspond to the original one.

Chip H.
 
I was also doubtful, as I have never seen a language or compiler support anything like copying an enum. I just did it using the way I did in the first post, but since the enums I wanted to copy only had a few members, it wasn't bad.

"Programming is like sex, one mistake and you have to support it forever."

John

johnmc@mvmills.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top