473,799 Members | 3,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to publicly expose an enum from a class library

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
Nov 20 '05 #1
4 3993
"Don" <un*****@oblivi on.com> schrieb
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.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
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
"Armin Zingler" <az*******@free net.de> wrote in message
news:ev******** ******@TK2MSFTN GP12.phx.gbl...
"Don" <un*****@oblivi on.com> schrieb
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.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
* "Don" <un*****@oblivi on.com> scripsit:
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).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Don
I didn't know you could do that. That is preferable to either method and
feels more "correct".

- Don

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:bu******** ****@ID-208219.news.uni-berlin.de...
* "Don" <un*****@oblivi on.com> scripsit:
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).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
302
by: Jonas | last post by:
Hi! I'm writing an application with VS.NET 2003 in C# that will use an existing class library written in VB.NET, which contains a public enum in a public module, see below. The CheckStringLength method is available when I use the class library, but the enum is not. I've tried to create a new VB.NET class library with the exact same code as below, and from that one I can access the enum.
3
2006
by: M | last post by:
I can pass in a string to a Web User Control, but I haven't been successful passing in an enum. I declared my enum as a public variable in my Web User Control itself. Thanks in advance.
2
7921
by: Gerard Stafleu | last post by:
I have a project with the following module: Module mdlDeclarations Public Enum getMethod gmFirst gmLast End Enum End Module and the following class:
5
6936
by: Alex Stevens | last post by:
Hi All, In the absence of any predefined standards, I was wondering how to name and implement my enum in a class. My dilema is: When I (for example) have an integer property in my class I'll use a class level variable called mintCount and the property sub accepts a variable called intCount and then assigns mintCount = intCount.
6
4914
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like this: public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 }; However, the resulting wsdl omits the actual flag values: - <s:simpleType name="Colors">
3
6329
by: Miguel Ferreira via .NET 247 | last post by:
Hi ! I have developed a class Library with several classes and methods. Its working fine with a windows forms test application, but now i need to create a webservice that will expose those methods. Do i have to create a method signature replica to all interfaces and methods, that will consume the internal class library, like this: <WebMethod()> _ Public Function Method1() As TypeDefinedInClassLibrary 'Call Method1 in class library...
3
3454
by: Ant | last post by:
Hi, Im wrapping a MailMessage object & need to expose the Priority property. This property is set to a value of the 'MailPriority' enum. My question is, how do I create a member that accepts this enum as a value? as a field named Priority: public MailPriority Priority; //doesn't work So that I can set it from the Email instance like this:
34
11205
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code snippet that I wrote today that gives me an instant implementation of the pattern. I could easily just always use such an implementation instead of a standard enum, so I wanted to know what you experts all thought. Is there a case for standard enums?
0
1745
by: John Smith | last post by:
What's the magical incantation to be able to expose an enum to COM? namespace NThingy { // I want to be able to access this like an old school midl enum public enum FileStatusCodes { HOLD = 0, PENDING = 1, COMPLETED = 2
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10219
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10025
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6804
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.