对于 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/