For a Type
, there is a property IsClass
, but how to know a Type
is a struct?
Sorry, I have to add some more information.
- I am using C#.
- Although
IsValueType
is a necessary condition, it is obviously not enough. For an Integer is a value type also.
use this:
From help:
Type::IsValueType Property Gets a value indicating whether the Type is a value type. Value types are types that are represented as sequences of bits; value types are not classes or interfaces. Value types are referred to as "structs" in some programming languages. Enums are a special case of value types.
If it's a value type (e.g., a
struct
), useType.IsValueType
.Well then, I guess for your requirement then this comes close:
but still
DateTime
isn't covered by that for example. Maybe you would have to add further types you want to exlude manually.You can use
IsValueType
.If you are talking about c#, you can use the
IsValueType
property.