How to determine if Type is a struct?

.net, c#, struct, types

Solution

Type.IsValueType should do the trick.

(pinched from here)

Problem

Given a `PropertyInfo` instance, which has a `Type` property, how does one determine if it is a struct? I found there are properties such as `IsPrimitive`, `IsInterface`, etc. but I'm not sure how to ask for a struct? EDIT: To clarify question. Suppose I have a method: ``` public Boolean Check(PropertyInfo pi) { return pi.Type.IsStruct; } ``` What do I write instead of `IsStruct`?

Original source

Related problems