CodePlexProject Hosting for Open Source Software
Figured out that one can lookup the source text of an enum value by accessing the _map property. This is a hack though, what is the preferred way to do it?
enum MyEnum {
A,
B
}
var x = MyEnum.B; // x == 1
var src = MyEnum['_map'][x]; // src == "B"
You got it. The _map field gives you a way to get back to the names of the enums.
From: jonturner
Potentially. In a sense, it's more of a convenience which matches closely to how you'd do it in JS. That said, you could try submitting a feature request and see if there's enough support for people who want to print out enums more cleanly.
Are you sure you want to delete this post? You will not be able to recover it later.
Are you sure you want to delete this thread? You will not be able to recover it later.