我想做的是获取 Type
的 enum
,它嵌套在 Class
中,只有该枚举器的名称作为字符串。
例子:
public static class MyClassWithEnumNested
{
public enum NestedEnum
{
SomeEnum1,
SomeEnum2,
SomeEnum3
}
}
我需要得到
Type type = //what shall I write here?
Type type = Type.GetType("MyClassWithEnumNested.NestedEnum");//that doesn't work
有什么办法可以在运行时得到这个Type
吗?
提前致谢:)
最佳答案
这应该有效:
Type.GetType("MyClassWithEnumNested+NestedEnum");
关于c# - 获取只有字符串的嵌套枚举类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11081900/