gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 20:10:56 25 4
gpt4 key购买 nike

我想做的是获取 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com