if you are doing this from another class (as I was the other day when i
ran into this), there are two things.
Example 1: Accessing from different class, same namespace
namespace project.namespa ce1
{
public class MyClass
{
public enum IDkind
{
PersonID,
EntityID,
PlaceID
}
/// <summary>
/// Gets an ID value of a particular KIND
/// </summary>
/// <param name="K">The kind of ID desired</param>
public int IDget(IDkind K)
{
return (int) IDsArray.GetVal ue(new int[] {(int) K});
}
}
public class OtherClass
{
//here you would reference the enum by
//MyClass.IDKind. PersonID
//tying . after IDKind should pop up the members
}
}
Example 2:
however, if you are going to be referenceing from a different namespace:
namespace someothernamesp ace
{
public class OtherClass
{
//here you cannot reference the enum by
//MyClass.IDKind. PersonID
}
}
what you would need to do in this case is put the enums you want
accessible OUTSIDE of the class, but inside the namespace
namespace project.namespa ce1
{
//put enum here
public enum IDkind
{
PersonID,
EntityID,
PlaceID
}
public class MyClass
{
/// <summary>
/// Gets an ID value of a particular KIND
/// </summary>
/// <param name="K">The kind of ID desired</param>
public int IDget(IDkind K)
{
return (int) IDsArray.GetVal ue(new int[] {(int) K});
}
}
public class OtherClass
{
//now you can just access via the enum name
IDKind.PersonID
//because of shared namespace
//and intellisense will find it.
//and this solves the problem of accessing from another
//namespace as illustrated below
}
}
then in the other namespace,
using project.namespa ce1
namespace someothernamesp ace
{
public class someclass
{
//you can just access the enum by name
IDKind.PersonID
//and hitting . will have intellisense bring up the
//members
}
}
hope that helps.
Greg Ewing [MVP] wrote:
frederick, have you tried typing IDKind. int he method signature? After you
type the Enum name it will give you a drop down of the valid values.