Enum Declaration

enum MState {Idle,Wander}
MyState MState.Idle;

It throws an Error: Error CS0246: The type or namespace name ‘MyState’ could not be found

I Tried This

enum MState {Idle,Wander}
MyState = MState.Idle;

but It didn’t worked and It throws this Error: Error CS1519: Unexpected symbol ‘=’ in class,struct, or interface memeber declaration

thanks for helping

I think you meant, MState mystate= MState.Idle;.
When declaring a variable you need [type][variablename]=[value]

1 Like

variable declaration format (in this case) should be :

TypeCast variableName = value;

enum MState {Idle,Wander}
MState myState = MState.Idle;

edit : whoops, too slow :slight_smile: