Is it possible, in C# .NET, to convert a list of string into an enum of values.
Let's imagine I get the list of string from somewhere (API call for example) and I want to convert it to an enum like that :
List<string> MyList = MyService.GetList();
//MyList = {"Red", "Blue", "Yellow"}
//Here the code to create my enum from MyList
//... Somewhere else in the code
var colorRed = MyEnum.RED;
var colorBlue = MyEnum.BLUE;
Is it possible here to create the MyEnum enum, which doesn't exists yet, and if yes, how ? If it's not, what workaround could I use?
I have tried to use the list only, but I need an enum in order to use it like that
MyEnum.RED;