i have a question about enums that the codes are below:
namespace space
{
public enum MyEnums
{
Enum1,Enum2,...
}
}
namespace space
{
Well syntactically the only difference is that you'd preface the enum type with the containing class:
MyClass.MyEnums.Enum1
versus just
MyEnums.Enum1
(in both cases the namespace is assumed to be covered with a using
directive)
However, containing it within the class also lets you apply accessibility differently - you could have a private
enum that is only usable within that class, while an enum within a namespace must be either public
or internal
.