Getting a nested enum type having only a string?

What I'm trying to do is get Type of enum , which is nested in Class , having only the name of this enumerator as a string.

Example:

 public static class MyClassWithEnumNested { public enum NestedEnum { SomeEnum1, SomeEnum2, SomeEnum3 } } 

I need to get

 Type type = //what shall I write here? Type type = Type.GetType("MyClassWithEnumNested.NestedEnum");//that doesn't work 

Is there a way to get this Type at runtime?

Thanks in advance:)

+7
source share
1 answer

This should work:

 Type.GetType("MyClassWithEnumNested+NestedEnum"); 
+10
source

All Articles