Convert Enum Name to String

I have searched like bitten by monkeys but can not find a solution: How can I get the enum-name of an enum?


Dim myEnum As MyClass.Levels = MyClass.Levels.LOW Dim enumName As String = myEnum...???? 'should be: enumName=LOW

In C# this would be: myEnum.ToString();

Enums in Xojo are Integers, that’s why there is no ToString call. There is a feedback case to support string enums (<>), which has been reviewed for quite a while now.

The roundabout way, which I’ve used somewhere, is to have a dictionary mapping the names. At the moment I needed to display the enum’s name in some rare occasions so I just did a dictionary. I always found it to be a bit of double-work but it was still worth it than just using the dictionary.


@Maximilian: Of course I am aware that enumeration of type Integer are. Nevertheless, it should be possible for the compiler to save the enum names (the strings).

@Eduardo: I need it only for printing some human readable text. The idea with a two-dimensional array or dictionary is crossed my mind. Unfortunately it’s time-consuming and error-prone.

So at the moment it’s just not possible. Thanks to both of you for the answer.