.NET:注意 Primitive 这个小坑

背景

有个需求,需要递归遍历类型的所有属性(属性的属性),然后对不同的类型做不同的处理,或者只是将类型分为三类:Primitive、Complex 和 Collection。因为 MS 的 Type 提供了 IsPrimitive 属性,这里重点说下我对 Primitive 的期望,原本以为肯定要包含:Decimal,有可能包含:String,可是并非如此。

Type.IsPrimitive Property

官方地址:http://msdn.microsoft.com/en-us/library/system.type.isprimitive(v=vs.110).aspx

The primitive types are BooleanByteSByteInt16UInt16Int32UInt32Int64UInt64IntPtrUIntPtrCharDouble, and Single.

If the current Type represents a generic type, or a type parameter in the definition of a generic type or generic method, this property always returns false.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值