c# - 获取只有字符串的嵌套枚举类型?

标签 c# enums runtime

我想做的是获取 Typeenum,它嵌套在 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/

相关文章:

c# - 如何通过前缀从 azure 存储中获取 blob,同时忽略虚拟文件夹?

c++ - 使用位集适配器从operator []返回引用

algorithm - 线性递归、二元递归与运行时间的关系

java - 在运行时更改类文件

c++ - Mex 运行时错误 : Unexpected standard expression

c# - 无法将类型 'System.String' 的对象转换为类型 'System.Collections.Generic.List` 1

c# - 无法创建类型为 'System.Int32[]' 的空常量值。

c# - 为什么 ScriptEngine 没有 Execute 方法了?

hibernate - 实体类和枚举查找类之间的一对多关系

java - 枚举值获取?