473,378 Members | 1,066 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,378 software developers and data experts.

how to create a public enum to be used accross classes in my solut

Hello,

I would like to create an enum that can be used accross all the classes in
my windows solution. How can I do this.

TROUBLESHOOTING
I created a new .cs file in my windows solution. I call it Enumerations.cs.
In this file I have written the following...
using System;

using System.Collections.Generic;

using System.Text;

namespace PatternsUsingGIS

{

public enum GeodatabaseTypes

{

PersonalGeodatabase,

FileGeodatabase,

SDEGeodatabase

}

}
I want to use this in another class (.cs) file. For example I want to type:

//method call
public void SayType(enum GeodatabaseTypes)
{
//do something
}
How do I do this?
Apr 21 '07 #1
2 1447
di****@newsgroup.nospam <di****@newsgroup.nospam.donotspamwrote:
I would like to create an enum that can be used accross all the classes in
my windows solution. How can I do this.
<snip>

I want to use this in another class (.cs) file. For example I want to type:

//method call
public void SayType(enum GeodatabaseTypes)
{
//do something
}

How do I do this?
You can't do that, but you can do:

public void SayType (GeodatabaseTypes type)
{
....
}

Basically an enum is a type, and the syntax of using it is like any
other.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 21 '07 #2
di****@newsgroup.nospam wrote:
Hello,

I would like to create an enum that can be used accross all the classes in
my windows solution. How can I do this.

TROUBLESHOOTING
I created a new .cs file in my windows solution. I call it Enumerations.cs.
In this file I have written the following...
using System;

using System.Collections.Generic;

using System.Text;

namespace PatternsUsingGIS

{

public enum GeodatabaseTypes

{

PersonalGeodatabase,

FileGeodatabase,

SDEGeodatabase

}

}
I want to use this in another class (.cs) file. For example I want to type:

//method call
public void SayType(enum GeodatabaseTypes)
{
//do something
}
How do I do this?
Either add a using statement that includes the namespace, or specify the
complete type name: PatternUsingGIS.GeodatabaseTypes.

To use the enum you don't use the enum keyword, just the name:

public void SayType(GeodatabaseTypes dbType)

--
Göran Andersson
_____
http://www.guffa.com
Apr 21 '07 #3

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

Similar topics

7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Dennis C. Drumm | last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am building a custom MessageBox dialog that has, among other things, a few new button options (yes to all, no to all, etc.)...
1
by: Bill Cohagan | last post by:
I've got an abstract class (say foo) and I'd like to define an Enum (say bar) within that class so that I can then refer to foo.bar.<one of the enum labels> from within other parts of the program....
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();...
2
by: Russell Mangel | last post by:
I am trying to create a property which returns an enum. The following class does not work, can someone fix it? I am using VS2003 C++ public __gc class Drive { public: Drive(){} __property...
3
by: moondaddy | last post by:
How can I create a public variable similar to an Enum, but rather than returning integer values it would return String values? -- moondaddy@nospam.com
4
by: moondaddy | last post by:
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? ...
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...
12
by: Cmtk Software | last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI managed c++ and from C#. I defined the following enum in a VS dll project set to be compiled with the /clr switch: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.