I've a audit class that recovery everything by reflection. I need in my actual point know if an specific property is an Enum, but I'm getting a strange behavior:
During foreach iteration q.PropertyType.IsEnum
return false. And using Quick watcher the property is really false, and the IsClass too. So this is basically nothing :)
Studying a little more about the problem I found that Nullable Enum returns false in IsEnum
. How can I ignore this nullable and verify if the property is an enum or not?
Enum types cannot be nullable.
IsEnum will return false
when your property is of a nullable type. In this case, calling Nullable.GetUnderlyingType on q.PropertyType
will return the type you want. Then you can check with IsEnum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With