How to publicly expose an enum from a class library

D

Don

It is possible to expose an enumerated type from within a class library so
that other projects referencing that class library will see it in the
class's namespace? For example, if I have a class library called "foo"
which has a public enumerated type called "bar" declared in a module of that
class library, is it possible for a different project referencing "foo" to
be able to declare variables of type "foo.bar"?

- Don
 
A

Armin Zingler

Don said:
It is possible to expose an enumerated type from within a class
library so that other projects referencing that class library will
see it in the class's namespace? For example, if I have a class
library called "foo" which has a public enumerated type called "bar"
declared in a module of that class library, is it possible for a
different project referencing "foo" to be able to declare variables
of type "foo.bar"?

You don't have to put it in a module (but of course you can). If you declare
the Enum Public, there should be no problem. If you put it in a module or a
class, the module/class must also be public.
 
D

Don

Okay, that's what the problem was. I had put it in a module, but had not
delcared the module as public. Thanks.

- Don
 
H

Herfried K. Wagner [MVP]

* "Don said:
It is possible to expose an enumerated type from within a class library so
that other projects referencing that class library will see it in the
class's namespace? For example, if I have a class library called "foo"
which has a public enumerated type called "bar" declared in a module of that
class library, is it possible for a different project referencing "foo" to
be able to declare variables of type "foo.bar"?

Just declare the enum directly in the namespace (not within a module or
class).
 
D

Don

I didn't know you could do that. That is preferable to either method and
feels more "correct".

- Don
 

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

Top