我有一个枚举,我想检查枚举类型是否为ulong.
到目前为止尝试过:
var checkValue = Enum.GetUnderlyingType(param.ParamType); // param is enum
if (checkValue is ulong){ } // doesn't work
var checkValue = param.value;
if (checkValue is ulong){ } // doesn't work
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
Enum.GetUnderlyingType
返回一个类型为的对象Type
,它确实不是一个ulong
,它是ulong
类型本身:)
试试这个:
if (checkValue == typeof(ulong))
Run Code Online (Sandbox Code Playgroud)