Currently, Enum.Parse supports only the comma as the value separator, so that
MemberOne,MemberThree
will be correctly parsed but
MemberOne|MemberThree
won’t. Is there any way to force Enum.Parse to accept other characters as the separator (for example, the ‘|‘) without using String.Replace on the expression parameter?
You could add your own custom helper method for the Enum class like this:
Then use it like this:
I'm not really sure if this meets your criteria - it's still using string.Replace, but you don't have to use it in the parameter.
You could also have a method like this which could accept multiple options without specifying the separator on each call:
which could be called like this: