String representation of enum value

Marek Janukowicz marek at janukowicz.net
Sun Aug 4 06:58:30 PDT 2013


Given following code:

enum ErrorCode {
  BAD_REQUEST,
  UNKNOWN
}

ErrorCode code;

is there any way to get string representation of code with regard to values 
defined in enum? I mean - if code == 0, I'd like to get a string 
"BAD_REQUEST", if it's == 1, I'd like to get string a "UNKNOWN". Of course 
I'd like to use something more consise and elegant than a switch :)

-- 
Marek Janukowicz


More information about the Digitalmars-d-learn mailing list