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

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.
 
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)
 
Back
Top