I’d like for the user to provide an enum name, say “Color”, and a value, say “red”, and tell them whether or not that is a member value of that enumeration, or if the enumeration even exists.
How can I do this?
In the past, I have used Type.GetType(“UserProvidedType”).Parse / Convert.ChangeType, but this doesn’t appear to work when the user provided type is an enumeration. Please see:
Parsing to primitive types, based on user input in c#
for past solutions that don’t appear to work in this context.
Thanks.
1 Answer