Does C# offer a way to create Enum type from scratch using reflection?
Suppose, I have a collection of strings: {"Single", "Married", "Divorced"} and I’m willing to build the following enum type in runtime:
enum PersonStatus
{
Single, Married, Divorced
}
Is this somehow possible?
Not without doing really gnarly things like generating assemblies using Emit. How would you use such an enum anyway? Whats the real goal here?
EDIT: Now that we know what you really want to do, this page suggests that you can acheive your goal using code like the following: