By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,574 Members | 1,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,574 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.