Converting MemberInfo[] to Enum
c#, enums, reflection
Solution
You should simply use `Enum.GetValues`. That's exactly what it does - use reflection to get the enum fields:
Assembly s = Assembly.Load("test");
Type type = s.GetTypes()[1];
object[] values = Enum.GetValues(type);
object myValue = values.First(v => v.ToString() == "MyValue");
Problem
I've been searching for a while but didn't find the solutions. I have an assembly in a GAC. I have to to load it using reflection. After that I need to get and address to Enum. But instead I can just get `MemberInfo[]`. I don't understand how to convert `MemberInfo[]` to `Enum`. I have code like this: ``` //test assembly contains public class MyClass { public enum MyEnum { MyVavue, MyValue2 } } Assembly s = Assembly.Load("test"); Type type = s.GetTypes()[1]; MemberInfo[] memberInfos = type.GetMembers( BindingFlags.Public | BindingFlags.Static); //I need to convert memberInfos to MyEnum //and after that receive ---> MyEnum.MyValue <--- ```