473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 2138
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: DPfan | last post by:
What's exactly the meaning of "code reuse" in C++? Why such kind of reuse have more advantages over the counterpart in other language like in C? How is "code reuse" realized in C++? By...
20
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
21
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
3
by: Simon | last post by:
Hi all, I'm hoping that some of you clever chaps could offer me some advice on code reuse. You see, whenever I make applications, I typically only find very limited
13
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
1
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
2
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
34
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...
19
by: jacob navia | last post by:
There is an interesting discussion running in Slashdot now, about code reuse. The thema of the discussion is here: < quote > Susan Elliot Sim asks: "In the science fiction novel, 'A Deepness...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.