gpt4 book ai didi

VS2005 中的 C# : can you check whether an integer is declared in a given Enum type?

转载 作者:太空宇宙 更新时间:2023-11-03 20:40:16 25 4
gpt4 key购买 nike

对于 VS2005 中的 C#,有没有办法检查整数是否属于 Enum 类型?

例如:

if number in CustomerType { ... }

在哪里

enum CustomerType
{
A = 0;
B = 1;
C = 2;
}

最佳答案

Enum.IsDefined(Type enumType, Object value)你在找什么?

代替您的 if 语句:

if (Enum.IsDefined(typeof(CustomerType), number))
{
...
}

关于VS2005 中的 C# : can you check whether an integer is declared in a given Enum type?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3138565/

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