Convert string into enum

A handy tip I just discovered, if you want to convert a String into an Enum type in C#, you can call:

object Enum.Parse(System.Type enumType, string value, bool ignoreCase);

You can then cast this into the required type, and it will save you from creating huge switch statements instead.

Add a Comment

Your email is never published nor shared. Required fields are marked *

*
*