#Enum By Indext

1 messages · Page 1 of 1 (latest)

regal helm
#

hi, how can I find the indext number of the enum ?
and so, how can I set the enum case from int ?
thanks

civic dome
#

For both cases you can simply cast them under most conditions.

int index = (int) enumValue;
...
YourEnum enumValue = (YourEnum)index;

You can also index the values field of the enum, though if you specify the values of the enums to be different than their default ordinals the index can be different than the value of the enum.

regal helm
civic dome
#

I'm pretty sure by default the first enum is 0 unless specified otherwise

#

easy enough to check though, printing out the enum casted to int

regal helm
civic dome
#

No problem hope it works