Enum value by string?

J

Jon Davis

What's the easiest and cleanest way to fetch an enum value by its name?

For instance,

public enum Boy {
Bob, Billy, Joe
}

public Boy GetBoy(string boyName) {
return ?? // and no, I refuse to use switch/case.
}

Thanks,
Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

about enum 3
Enum Extentions 7
enum string value 3
Object with field that can be any type 15
Deserialization of invalid enum values 3
Enum question 5
Creating dropdown through enum 3
Arrays of List collections 4

Top