This is probably a stupid question, but I can\'t seem to do it. I want to set up some enums in one class like this:
public enum Direction { north, east, south,
It's public, but defining an enum inside a class makes it an inner type of that class. For instance:
namespace MyNamespace
{
public class Foo
{
public enum MyEnum { One, Two, Three }
}
}
In order to access this enum from another class in the MyNamespace
namespace, you have to reference it as Foo.MyEnum
, not just MyEnum
. If you want to reference it as simply MyEnum
, declare it just inside the namespace rather than inside the class:
namespace MyNamespace
{
public class Foo { ... }
public enum MyEnum { One, Two, Three }
}