I notice that in C#, when I have an Enum, say:
class ClassObject {
public static Enum EventType = {Click, Jump, Etc};
}
And when I have to access it, I have to go through it's main class and it is very verbose. For eg:
ClassObject.EventType.Click
I hope that I could access it in a shorter manner, say:
EventType.Click
, will allow me get that.
So what I thought I could try to create a separate class and extend it from Enum:
class EventType : Enum {
Click, Jump, Etc;
}
However, this I'm getting a syntax error for this.
Actually, creating another separate class just for this purpose is a little troublesome and I don't even know if this is a good practice or not. But ideally, I just wish to shorten the name and probably avoid the need for having to type the class name before accessing the enum. Is this possible?
You can put the enum at the same depth of the class, it doesn't have to be a class member
namespace Test
{
public enum EventType
{
Click,
Jump,
Etc
};
class ClassObject { }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With