Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting type of nested enum having only string?

Tags:

c#

enums

runtime

What i'm trying to do is get Type of enum which is nested in Class having only name of that enumerator as string.

example:

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

i need get

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

Is there any way to get this Type in runtime?

Thanks in advance:)

like image 903
Harry89pl Avatar asked Jun 18 '12 11:06

Harry89pl


1 Answers

This should work:

Type.GetType("MyClassWithEnumNested+NestedEnum");
like image 64
Lucero Avatar answered Oct 15 '22 23:10

Lucero