472,779 Members | 2,826 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 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 2110
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.