How to determine if an object is a value type

I could use Type.IsValueType to figure this out straightforwardly in .net 4.5, but when I build generic apps using a portable library it doesn't have an equivalent method to determine if a type is a value or not.

Is there any more trick to find this?

+3


source to share


2 answers


One workaround found:



TypeOf (ValueType) .IsAssignableFrom (type)

+1


source


Try it type.GetTypeInfo().IsValueType

. Also make sure you have a using statement for System.Reflection so an extension method is available GetTypeInfo()

.



+4


source







All Articles