How to parse enum from a string ?

Dennis dkorpel at gmail.com
Wed May 27 17:36:35 UTC 2020


On Wednesday, 27 May 2020 at 17:33:33 UTC, Vinod K Chandran wrote:
> I am saving this enum values as string in database. So, when i 
> retrieve them from the database, how can i parse the string 
> into TestEnum ?

Use `to` from `std.conv`.

```
import std.conv: to;
void main() {
     assert("Received".to!TestEnum == TestEnum.Received);
}
```


More information about the Digitalmars-d-learn mailing list