Check if the enum type is ulong

I have an Enum and I want to check if the enum type is ulong.

Tried so far:

 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

      

any ideas?

+3


source to share


2 answers


Enum.GetUnderlyingType

returns an object of type Type

, so it really isn't ulong

, it's the type ulong

itself :)

Try the following:



if (checkValue == typeof(ulong))

      

+9


source


Try this well:



var enumType = param.GetType();

var utype = Enum.GetUnderlyingType(entype);

if(utype == typeof(ulong))

      

0


source







All Articles