Reputation: 317
I would like get in code name of base enum not value or label. With this code I get label not name:
info(enum2str(AssetGroup::AssetGroup1));
Upvotes: 4
Views: 16202
Reputation: 259
Simply use enum2Symbol()
For example:
enum2Symbol(enumNum(KPAssetGroup), KPAssetGroup::PWNiP);
Upvotes: 11
Reputation: 2236
You can do this as follows.
1 - Declare a EnumId
variable.
2 - Declare a dictEnum
variable.
3 - Declare a int
variable.
4 - Use index2Symbol
method of dictEnum
to get code name of base enum.
Optional - Use index2Label
method of dictEnum
to get label of base enum.
Code example:
static void StackOverflow(Args _args)
{
EnumId Id = enumNum(SalesType);
DictEnum dictEnum = new DictEnum(Id);
int EnumValue = enum2Int(SalesType::Journal); //Replace Base enum for Your Base Enum.
info(dictEnum.index2Symbol(EnumValue));
//info(dictEnum.index2Label(EnumValue)); //Optional only reference
}
Upvotes: 5