如何确定类型是一个结构? [英] How to determine if Type is a struct?

查看:154
本文介绍了如何确定类型是一个结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个的PropertyInfo 实例,其中有一个键入属性,一个人如何确定它是否是一个结构?我发现有属性,如 IsPrimitive IsInterface 等,但我不知道如何索要结构?

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?

编辑: 为了澄清问题。 假设我有一个方法:

To clarify question. Suppose I have a method:

public Boolean Check(PropertyInfo pi)
{
   return pi.Type.IsStruct;
}

什么我写的,而不是 IsStruct

推荐答案

Type.IsValueType应该做的伎俩。

Type.IsValueType should do the trick.

(从<一掐href="http://stackoverflow.com/questions/2083012/reflection-has-isclass-but-no-isstruct">here)

这篇关于如何确定类型是一个结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆