Skip to main content

Cloud

Parsing a String to an Enum

Here is a generic extension method to get back an enum value from a string. It improves upon the Enum.Parse method by doing the following: 1) it encapsulates the cast of the value to the enum type; 2) supports an optional case-insensitive search; and 3) returns a boolean to indicate success or failure (rather than throw an exception).


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

PointBridge Blogs

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram