Get Enum Value from String

Here is a quick tip.  If you have the following Enum

And you want to get the enum value from a string, you can:

If you try to parse a string that doesn’t exist e.g. "YEARLY", an ArgumentException exception is thrown with a message "Requested value ‘YEARLY’ was not found".

Also note that the string is case-sensitive, so "Weekly" will also throw the same exception.