Enum value by string?

  • Thread starter Thread starter Jon Davis
  • Start date Start date
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


Back
Top