String to enum
useo
useo6 at start.bg
Fri Dec 10 08:40:45 PST 2010
Hi,
does anyone know how I can cast a string to an enum which also
contains strings? For example:
enum MyENUM : string {
x = "123"
y = "456"
z = "789"
}
...
string myString = X;
to!(MyENUM)(myString); // Error: cannot implicitly convert
expression (_adDupT((& D12TypeInfo_Aya6__initZ),s)) of char[]...
cast(MyENUM) myString; // Does work, but it seems that other values
like MyENUM.a, MyENUM.b... are also successfully casted to MyENUM but
MyENUM doesn't contain a, b or similiar invalid/undefined values.
I hope anyone can solve the problem... thanks.
More information about the Digitalmars-d-learn
mailing list