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

G

Guest

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?
 
J

Jon Skeet [C# MVP]

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

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.
 
G

Guest

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top