How to share an Enum accross DLLs

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I have some pubic Enums I like to use throughout my application. Now I'm
parsing the application out into smaller DLLs or projects. How an I share a
common Enum across all the projects?

Thanks.
 
You should be able to share the Enums if you declare them public in the Class
module before the Class statement. For ezample, in a class module or class
library, etc.

Imports ...............
Imports ..............
Public Enum myenum
First
Second
End Enum

Public Class MyClass
............
............
End Class
 
moondaddy said:
I have some pubic Enums I like to use throughout my application. Now I'm
parsing the application out into smaller DLLs or projects. How an I share
a common Enum across all the projects?

Implement the enum in one project and then add a reference to the project
from the other class library projects. Import the namespace containing the
enum and use it ;-). To add a project reference, select the project in
solution explorer and choose "Add reference..." from its context menu. In
the "Add reference..." dialog select the "Projects" tab and add the
reference.

Notice that it's important to define the enumeration only in one of the DLLs
and then use this enumeration instead of defining an enum with the same name
in each of the DLLs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top