469,268 Members | 975 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,268 developers. It's quick & easy.

How to reuse enum-definition?

I want to define an enum for possible languages in my application. My
enum look like this:

Public Enum Languages
English = 0
Portuguese = 1
End Enum

How can i reuse this enum in the rest of my application (in different
classes in different projects)?

I have tried to make a specific class for this:

Public Class Languages

Public Enum Languages
English = 0
Portuguese = 1
End Enum

End Class

I can then inherit this class from other classes and use the enum. But
this does not work when I want to use the enum in a form. The form
already inherits: System.Windows.Forms.Form and can only inherit from
one class.

I originally put the enum in a startup module. This way I made it
global and could use it within my UserInterface project. But then I
could not use it in the other projects (entity and business tier
project).

How do i define enum just once and be able to use different places?
Jul 21 '05 #1
3 1951
You do not have to wrap the enum in a class you can use it from any other
projects provided your enum is public and and you created assembly where the
enum is defined in as a dll.

"Kenneth" <k.********@get2net.dk> schrieb im Newsbeitrag
news:13**************************@posting.google.c om...
I want to define an enum for possible languages in my application. My
enum look like this:

Public Enum Languages
English = 0
Portuguese = 1
End Enum

How can i reuse this enum in the rest of my application (in different
classes in different projects)?

I have tried to make a specific class for this:

Public Class Languages

Public Enum Languages
English = 0
Portuguese = 1
End Enum

End Class

I can then inherit this class from other classes and use the enum. But
this does not work when I want to use the enum in a form. The form
already inherits: System.Windows.Forms.Form and can only inherit from
one class.

I originally put the enum in a startup module. This way I made it
global and could use it within my UserInterface project. But then I
could not use it in the other projects (entity and business tier
project).

How do i define enum just once and be able to use different places?

Jul 21 '05 #2
Thanks cody. That sounds good. Unfortunately I dont know how to create
an assembly as you mention. Can you please help me?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3
Simply set the output target from Windows Exe to Library in the project
options.

"Kenneth Agerskov" <k.********@get2net.dk> schrieb im Newsbeitrag
news:uD**************@TK2MSFTNGP12.phx.gbl...
Thanks cody. That sounds good. Unfortunately I dont know how to create
an assembly as you mention. Can you please help me?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by DPfan | last post: by
20 posts views Thread by Glenn Venzke | last post: by
21 posts views Thread by Andreas Huber | last post: by
31 posts views Thread by Michael C | last post: by
3 posts views Thread by Simon | last post: by
1 post views Thread by Randy | last post: by
2 posts views Thread by Randy | last post: by
34 posts views Thread by Steven Nagy | last post: by
19 posts views Thread by jacob navia | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.