enum to string

Nick Sabalausky a at a.a
Tue Mar 10 17:54:48 PDT 2009


Is there any way to do this (preferably in D1) with reflection? (ie, without 
having to manually create a conversion func/lookup for every value of every 
enum.)

----------------------
enum Shape
{
    Square, Circle
}
char[] foo(Shape s)
{
    // ?????
}

// Either one of these, I don't really care which
assert(foo(Shape.Square) == "Shape.Square");
assert(foo(Shape.Square) == "Square");
----------------------




More information about the Digitalmars-d-learn mailing list