简体   繁体   中英

Determine if generated type is value-type

I have some types created via CodeDOM. Is there a way to determine if a type of a given property is a value-type?

For those declared within mscorlib it´s pretty easy as I can call Type.GetType and then check for Type.IsValueType . However for those types within my DOM we can´t use this approach as there´s no assembly to load the types from.

var codeType = code.Types[0].Members[0];
bool isValueType = // get the runtime-type to determine if it is value-type or not

The CodeTypeDeclaration.IsStruct property, despite its name, does exactly this — determines whether the type is a value type. See the documentation here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM